【发布时间】:2015-11-07 09:31:44
【问题描述】:
我有一个从网络摄像头的快照创建的 WritableBitmap。我想将它加载到 BitmapDecoder 中,以便裁剪图像。代码如下:
IRandomAccessStream ras = displaySource.PixelBuffer.AsStream().AsRandomAccessStream();
BitmapDecoder decoder = await BitmapDecoder.CreateAsync(ras); //Fails Here
displaySource 是来自网络摄像头的 WritableBitmap,我得到的异常是
{“找不到组件。(HRESULT 异常:0x88982F50)”}
这对我来说很奇怪,因为我可以将 displaySource 加载到我的 GUI 上,但我无法使用此代码。我也尝试将其切换到 InMemoryRandomAccessStream。从我看到的情况来看,这个异常没有任何 stackoverflow 解决方案。
displaySource 是从这段代码生成的:
// Create a WritableBitmap for our visualization display; copy the original bitmap pixels to wb's buffer.
// Note that WriteableBitmap doesn't support NV12 and we have to convert it to 32-bit BGRA.
using (SoftwareBitmap convertedSource = SoftwareBitmap.Convert(previewFrame.SoftwareBitmap, BitmapPixelFormat.Bgra8))
{
displaySource = new WriteableBitmap(convertedSource.PixelWidth, convertedSource.PixelHeight);
convertedSource.CopyToBuffer(displaySource.PixelBuffer);
}
其中预览帧是来自网络摄像头的 VideoFrame 设置。
提前致谢。
【问题讨论】:
标签: c# bitmap stream win-universal-app