【问题标题】:Converting a saved photo into a WritableBitmap in WinRT在 WinRT 中将保存的照片转换为 WritableBitmap
【发布时间】:2012-09-23 06:33:38
【问题描述】:

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

var writeableBitmap = new WritableBitmap(bitmap);

代码如下:

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

【问题讨论】:

    标签: image-processing windows-runtime


    【解决方案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;
                }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多