0

我拍了一张照片并保存了,但我需要对其进行图像处理。我尝试使用以下代码,但WritableBitmap不接受位图,它需要一个流。

var writeableBitmap = new WritableBitmap(位图);

这是代码:

CameraCaptureUI cam = new CameraCaptureUI();
var capturedImage = await cam.CaptureFileAsync(CameraCaptureUIMode.Photo);
if (capturedImage != null)
{
    var img = new BitmapImage();
    img.SetSource(await capturedImage.OpenReadAsync());
}
4

1 回答 1

1

这应该可以解决问题 - 您需要改用 OpenAsync。

 var dialog = new CameraCaptureUI();
            var file = await dialog.CaptureFileAsync(CameraCaptureUIMode.Photo);
            if (file != null)
            {
                var stream = await file.OpenAsync(FileAccessMode.Read);
                var img = new BitmapImage();
                img.SetSource(stream);
                AccountPictureImage.Source = img;
            }
于 2012-09-22T22:06:53.423 回答