ShevninAnton
ShevninAnton

Reputation: 159

Photo orientation after save VideoBrush to Image

I have problem with make photo on portrait orientation. I use VideoBrush on for Canvas.Background:

 <Grid x:Name="ContentPanel" Grid.Row="0" Margin="12,0,12,0">
    <Canvas Name="PhotoCanvas" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Grid.Row="1">
                    <Canvas.Background>
                        <VideoBrush x:Name="viewCamera">
                            <VideoBrush.RelativeTransform>
                                <CompositeTransform x:Name="cameraViewTransform" CenterX=".5" CenterY=".5"/>
                            </VideoBrush.RelativeTransform>
                        </VideoBrush>
                    </Canvas.Background>
     <Image Name="photoImage"></Image>
                   </Canvas>
            </Grid>

I save photo and added this photo to photoImage control:

Deployment.Current.Dispatcher.BeginInvoke(() =>
{
BitmapImage bImage = new BitmapImage();
bImage.SetSource(e.ImageStream);
photoImage.Source = bImage;
photoImage.Height = PhotoCanvas.ActualHeight;
photoImage.Width = PhotoCanvas.ActualWidth;
Camera.Dispose();
PhotoCanvas.Background = new ImageBrush();
}};

But I see photo on landscape orientation after save.

May be my code for orientation videoBrush brake all?:

switch (orientation)
            {
                case PageOrientation.Landscape:
                case PageOrientation.LandscapeLeft:
                    cameraViewTransform.Rotation = 0;
                    break;
                case PageOrientation.LandscapeRight:
                    cameraViewTransform.Rotation = 180;
                    break;
                case PageOrientation.Portrait:
                case PageOrientation.PortraitUp:
                    cameraViewTransform.Rotation = 90;
                    break;
                case PageOrientation.PortraitDown:
                    cameraViewTransform.Rotation = 270;
                    break;
            }
        }

How resolve this problem? Thank you!

Upvotes: 0

Views: 442

Answers (1)

FunksMaName
FunksMaName

Reputation: 2111

Are you using the PhotoCaptureDevice? try:

captureDevice.SetProperty(KnownCameraGeneralProperties.EncodeWithOrientation, cameraViewTransform.YourOrientation);

Upvotes: 1

Related Questions