0

我在纵向拍摄照片时遇到问题。我在 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();
}};

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

可能是我的方向 videoBrush 刹车代码吗?:

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

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

4

1 回答 1

1

您在使用 PhotoCaptureDevice 吗?尝试:

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

于 2013-09-12T14:13:03.217 回答