这是我到目前为止尝试的方向,我在potraitdown面临的问题,它显示图像在我想要做的两件事是第一个默认相机方向和第二个放大和缩小之前捕获图像
我在XAML中编写了这段代码
<Canvas x:Name="viewfinderCanvas" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,10">
<Canvas.Background>
<VideoBrush x:Name="viewfinderBrush">
<VideoBrush.RelativeTransform>
<CompositeTransform
x:Name="viewfinderTransform"
CenterX="0.5"
CenterY="0.5"
Rotation="-90" />
</VideoBrush.RelativeTransform>
</VideoBrush>
</Canvas.Background>
</Canvas>
这是针对方向C#
protected override void OnOrientationChanged(OrientationChangedEventArgs e)
{
if (cam != null)
{
if (e.Orientation == PageOrientation.LandscapeRight)
{
landscapeRightRotation = 180;
// Rotate for LandscapeRight orientation.
viewfinderBrush.RelativeTransform =
new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = landscapeRightRotation };
}
else if (e.Orientation == PageOrientation.PortraitUp)
{
landscapeRightRotation = -90;
viewfinderBrush.RelativeTransform =
new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = landscapeRightRotation };
}
else if (e.Orientation == PageOrientation.PortraitDown)
{
landscapeRightRotation = 0;
// Rotate for LandscapeRight orientation.
viewfinderBrush.RelativeTransform =
new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = landscapeRightRotation };
}
else
{
viewfinderBrush.RelativeTransform =
new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 0 };
}
}
viewfinderTransform.ScaleY = 0;
base.OnOrientationChanged(e);
}
答案 0 :(得分:0)
我能够通过添加两个
RenderTransform
和Slider
来解决放大和缩小问题,但仍然面临着方向问题 Xaml已更新
<Canvas x:Name="viewfinderCanvas" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,10">
<Canvas.RenderTransform>
<ScaleTransform x:Name="zoom"/>
<!--<CompositeTransform scalex="-1"/>-->
</Canvas.RenderTransform>
<Canvas.Background>
<VideoBrush x:Name="viewfinderBrush">
<VideoBrush.RelativeTransform>
<CompositeTransform
x:Name="viewfinderTransform"
CenterX="0.5"
CenterY="0.5"
Rotation="-90" />
</VideoBrush.RelativeTransform>
</VideoBrush>
</Canvas.Background>
</Canvas>
<Slider Foreground="White" Value="1" Opacity=".3" Background="White" Visibility="Visible" Name="zoomSlider" ValueChanged="zoomSlider_ValueChanged_1" Margin="0,570,0,10" />
和C#for zoomSlider_ValueChanged_1
private void zoomSlider_ValueChanged_1(object sender, RoutedPropertyChangedEventArgs<double> e)
{
try
{
zoom.ScaleX = zoomSlider.Value;
zoom.ScaleY = zoomSlider.Value;
zoom.CenterX = 10;
zoom.CenterY = 5;
}
catch (Exception)
{
}
}