我在我的应用程序中添加了相机,该应用程序全都是竖屏模式,因此希望保持这种方式。
以下是我在 .XAML 中使用的相关代码片段:
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
<Canvas x:Name="viewfinderCanvas" Width="480" Height="800" >
<!--Camera viewfinder -->
<Canvas.Background>
<VideoBrush x:Name="viewfinderBrush">
</VideoBrush>
</Canvas.Background>
</Canvas>
这是我的.XAML.CS文件中的设置代码。
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
if (PhotoCamera.IsCameraTypeSupported(CameraType.FrontFacing))
{
cam = new Microsoft.Devices.PhotoCamera(CameraType.FrontFacing);
}
else
{
cam = new Microsoft.Devices.PhotoCamera(CameraType.Primary);
}
cam.Initialized += new EventHandler<Microsoft.Devices.CameraOperationCompletedEventArgs>(cam_Initialized);
cam.CaptureCompleted += new EventHandler<CameraOperationCompletedEventArgs>(cam_CaptureCompleted);
cam.CaptureImageAvailable += new EventHandler<Microsoft.Devices.ContentReadyEventArgs>(cam_CaptureImageAvailable);
cam.CaptureThumbnailAvailable += new EventHandler<ContentReadyEventArgs>(cam_CaptureThumbnailAvailable);
viewfinderBrush.SetSource(cam);
}
问题在于我将手机竖屏并对着一个人。屏幕上显示的是这个人的头部在屏幕右侧,脚在屏幕左侧。然而当他们站在我面前时,他们的头应该在屏幕顶部,脚在底部,因为这些人不是超人。
看起来摄像头拍摄的图像在出现在屏幕上之前被旋转了-90度。
请问有人能解释一下发生了什么问题以及我需要实现哪些示例代码来解决这个问题吗?
谢谢, -Code