This is what i have tried so far for orientation and i am facing problem in potraitdown it shows image in up two thing that i want to do are First default camera orientation and Second Zoom in and Zoom out before capturing the image
I wrote this code in 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>
And this is for orientation 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);
}
I was able to solve the zoom in and zoom out by adding two things
RenderTransform
andSlider
but still facing the problem in orientation Xaml updated
<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" />
And 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)
{
}
}