积极答复者
转换BitmapImage 到 writeableImage

问题
-
BitmapImage^ bitmapImage =ref new BitmapImage(); Image image1; bitmapImage->UriSource =ref new Uri(Package::Current->InstalledLocation->Path + "FileSnapshot_163 204.png"); image1.Source = bitmapImage;
上述代码倒入了一个 bitmapImage,我想把他转换为一个writeablebitmap 代码:
WriteableBitmap^ bitmapSnap = ref new WriteableBitmap(nWidth,nHeight); IUnknown* pUnk = reinterpret_cast<IUnknown*>(bitmapSnap->PixelBuffer); IBufferByteAccess* pBufferByteAccess = nullptr; HRESULT hr2 = pUnk->QueryInterface(IID_PPV_ARGS(&pBufferByteAccess)); unsigned char *pWriteableBitmapBuffer = nullptr; pBufferByteAccess->Buffer(&pWriteableBitmapBuffer);
之后怎么取出 BitmapImage的图片数据 拷贝到 writeablebitmap呢??
谢谢~
答案
-
不能直接从 BitmapImage 取出图像数据,我们只有从这个 BitmapImage 的UriSource读取这个图像源文件,然后将读取的字节内容写入你的 WriteableBitmap buffer.
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
- 已标记为答案 Jie BaoModerator 2012年9月24日 10:38
全部回复
-
不能直接从 BitmapImage 取出图像数据,我们只有从这个 BitmapImage 的UriSource读取这个图像源文件,然后将读取的字节内容写入你的 WriteableBitmap buffer.
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
- 已标记为答案 Jie BaoModerator 2012年9月24日 10:38