我的xaml中有以下捕获元素代码。
<CaptureElement Width="400" Height="400" x:Name="cameraCapture" Stretch="UniformToFill" Margin="0,0,0,40">
</CaptureElement>
我的页面已加载
private async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
await captureManager.InitializeAsync();
cameraCapture.Source = captureManager;
await captureManager.StartPreviewAsync();
}
如果我将旋转设置为预览而不是在视图中它工作正常但保存的图像仍然旋转到90度。我怎样才能解决这个问题?
captureManager.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
答案 0 :(得分:1)
致电CapturePhotoToStreamAsync
后,您应该在流媒体上应用这些内容:
//create decoder and encoder
BitmapDecoder dec = await BitmapDecoder.CreateAsync(imageStream);
BitmapEncoder enc = await BitmapEncoder.CreateForTranscodingAsync(imageStream, dec);
//roate the image
enc.BitmapTransform.Rotation = BitmapRotation.Clockwise90Degrees;
//write changes to the image stream
await enc.FlushAsync();
这只是一个片段,但我想你明白了。 有关完整代码示例,请查看此处:https://dzone.com/articles/how-capture-photo-your-windows-0