将VideoBrush保存到图像后的照片方向

时间:2013-09-12 13:30:31

标签: c# silverlight windows-phone-7 windows-phone-8 windows-phone

我在纵向制作照片时遇到问题。 我在Canvas.Background上使用VideoBrush:

 <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>

我保存照片并将此照片添加到photoImage控件:

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();
}};

但是我在保存后会看到横向方向的照片。

可能是我的方向视频爆破刹车代码?:

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;
            }
        }

如何解决这个问题? 谢谢!

1 个答案:

答案 0 :(得分:1)

您使用的是PhotoCaptureDevice吗?试试:

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