【发布时间】:2014-12-09 04:48:45
【问题描述】:
我的应用应该保存来自相机的图像。我写了下面的代码:
-
初始化相机的方法。
Windows.Media.Capture.MediaCapture takePhotoManager; public async void InitializeCamera() { takePhotoManager = new Windows.Media.Capture.MediaCapture(); await takePhotoManager.InitializeAsync(); takePhotoManager.SetPreviewRotation(VideoRotation.Clockwise90Degrees); PhotoPreview.Source = takePhotoManager; await takePhotoManager.StartPreviewAsync(); // to stop it //await takePhotoManager.StopPreviewAsync(); } -
保存照片的方法:
public async void SavePhoto() { ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg(); var file = await KnownFolders.PicturesLibrary.CreateFileAsync("Photo.jpg", CreationCollisionOption.ReplaceExisting); await takePhotoManager.CapturePhotoToStorageFileAsync(imgFormat, file); } -
预览
<CaptureElement x:Name="PhotoPreview" FlowDirection="LeftToRight" HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="UniformToFill"> </CaptureElement>
我有两个问题: 1.预览没有填满整个空间
- 保存后我得到这样的结果:(没有旋转,两边都有透明层)。
谢谢
【问题讨论】:
-
也许回答this question 会有所帮助。您还可以找到一些信息here at this post。
-
谢谢,它解决了我与透明空间相关的问题。不幸的是,保存过程后旋转图像仍然存在问题,并在预览中填充所有空间。
-
您是否尝试过:
HorizontalAlignment="Strech" VerticalAlignment="Strech"of CaptureElement in XAML? -
不幸的是它没有任何改变。
-
你解决了轮播问题吗?
标签: c# rotation windows-runtime windows-phone-8.1