【问题标题】:Photo Capture stream to SoftwareBitmap照片捕获流到 SoftwareBitmap
【发布时间】:2016-01-28 19:45:26
【问题描述】:

我的代码:

var stream = new InMemoryRandomAccessStream();
ImageEncodingProperties properties = ImageEncodingProperties.CreateJpeg();
await _mediaCapture.CapturePhotoToStreamAsync(properties, stream);
IBuffer buffer = new byte[stream.Size].AsBuffer();
await stream.ReadAsync(buffer, (uint)stream.Size, InputStreamOptions.None);
SoftwareBitmap sfbmp = SoftwareBitmap.CreateCopyFromBuffer(buffer, BitmapPixelFormat.Bgra8, 4176, 3120); // Exception is thrown here

例外:

响应内存不足

老实说,我对位图缓冲区一无所知,所以任何人都可以帮助我吗?

【问题讨论】:

    标签: c# imaging


    【解决方案1】:

    我使用 BitmapDecoder 解决了这个问题

    var stream = new InMemoryRandomAccessStream();
    ImageEncodingProperties properties = ImageEncodingProperties.CreateJpeg();
    await _mediaCapture.CapturePhotoToStreamAsync(properties, stream);
    var decoder = await BitmapDecoder.CreateAsync(stream);
    SoftwareBitmap sfbmp = await decoder.GetSoftwareBitmapAsync();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-28
      • 1970-01-01
      • 1970-01-01
      • 2020-09-04
      • 2016-04-26
      • 1970-01-01
      • 1970-01-01
      • 2012-01-08
      相关资源
      最近更新 更多