我有一個WritableBitmap是從網絡攝像機的快照創建的。我想將它加載到BitmapDecoder中,以便裁剪圖像。下面是代碼:爲什麼我的WritableBitmap無法通過IRandomAccessStream找到?
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設置。
在此先感謝。