为答案添加更多说明:文档描述的一件事在这里没有提到是在 OnOrientationChanged 事件中调整了相对变换。另一个区别是 XAML 中未指定相对转换。
在文档 (How to: Create a Base Camera Application for Windows Phone) 中,矩形是用视频画笔填充的,如下所示:
<!--Camera viewfinder >-->
<Rectangle Width="640" Height="480"
HorizontalAlignment="Left"
x:Name="viewfinderContainer">
<Rectangle.Fill>
<VideoBrush x:Name="viewfinderBrush" />
</Rectangle.Fill>
</Rectangle>
然后,在代码隐藏中,OnOrientationChanged 事件根据方向旋转矩形:
// Ensure that the viewfinder is upright in LandscapeRight.
protected override void OnOrientationChanged(OrientationChangedEventArgs e)
{
if (e.Orientation == PageOrientation.LandscapeRight)
{
viewfinderBrush.RelativeTransform =
new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 180 };
}
else
{
viewfinderBrush.RelativeTransform =
new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 0 };
}
base.OnOrientationChanged(e);
}
本主题中的代码(对应于示例)被配置为仅使用横向,也许这就是为什么您只获取横向图像的原因(?)一开始,以下属性被添加到手机中: MainPage.xaml 中的 PhoneApplicationPage 元素:
SupportedOrientations="Landscape" Orientation="LandscapeLeft"
如果图像的方向仍然不正确,请将图像同步到您的 PC 并查看它们的方向是否正确,同时在那里(在您的 PC 上)查看它们。可能是 Beta 版的错误导致图像无法正确显示在设备上。
希望对您有所帮助。干杯