我試圖旋轉CameraPreviewImageSource使它看起來(只)在人像模式:旋轉CamerePreviewImageSource
private async Task InitializeAsync()
{
this.cameraPreviewImageSource = new CameraPreviewImageSource();
DeviceInformationCollection devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Devices.Enumeration.DeviceClass.VideoCapture);
String backCameraId = devices.FirstOrDefault(x => x.EnclosureLocation != null && x.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back).Id;
await cameraPreviewImageSource.InitializeAsync(backCameraId);
VideoEncodingProperties properties = await this.cameraPreviewImageSource.StartPreviewAsync();
double width = 1280;
double height = 720;
this.writeableBitmap = new WriteableBitmap((int)width, (int)height);
this.capturePreview.Source = this.writeableBitmap;
this.writeableBitmapRenderer = new WriteableBitmapRenderer();
this.jpegRenderer = new JpegRenderer();
this.cameraPreviewImageSource.PreviewFrameAvailable += OnPreviewFrameAvailable;
}
我也試過在XAML文件,但大部分的時間,結果是怪異(像90%的圖片被隱藏):
<Image x:Name="capturePreview" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="3" Width="auto" Height="auto" Canvas.ZIndex="0" >
<Image.RenderTransform>
<CompositeTransform CenterX="0.5" CenterY="0.5" Rotation="90" />
</Image.RenderTransform>
</Image>
任何想法?
你是什麼意思使它只出現在肖像模式?你的意思是說,無論他們以哪種方式轉動它,它總是以縱向模式出現?或者你的意思是不可見,除非在肖像模式? – 2014-11-04 17:46:47
「無論他們以哪種方式打開它,它總是看起來好像是在肖像模式下」 – 2014-11-04 18:08:04