BitmapImage到byte Windows 8 metro(WinRT)
我想在Windows 8应用程序中将BitmapImage
转换为byte []。 我知道如何使用Windows sdk做到这一点,但似乎无法让它适用于WinRT sdk。
一两篇post暗示我应该使用WritableBitmap
来实现这一点,但没有明确的例子。
将BitmapImage转换为Byte数组 (Windows)
以下是我发现的最好但对我来说仍然过于模糊
WinRT将图像加载到字节数组中
我会感激任何帮助。
您应该在这里查看WriteableBitmapEx项目 – http://writeablebitmapex.codeplex.com/这里讨论 – WinRT将图像加载到字节数组 ……来自答案…
基本上你需要将图像加载到WriteableBitmap中,然后通过调用PixelBuffer.AsStream()来访问它的像素缓冲区。
所有你需要的是:
- BitmapDecoder.GetPixelDataAsync()
- PixelDataProvider.DetachPixelData()
然后你有一个BitmapImage的字节数组!
请参阅以下内容: http : //msdn.microsoft.com/en-us/library/windows/apps/xaml/jj709939.aspx