0
我試圖讓BitmapImage
系列化上的Windows Phone 8工作,但似乎很多圖書館都是從WP SDK缺失相比,桌面C#應用程序...字節數組的BitmapImage WP
基本上我有一個Byte
陣列,我需要解析爲BitmapImage
進行顯示,但是我在網上找不到任何東西......任何幫助都非常感謝! :)
由於StackOverflow上的算法,認爲這個問題太瑣碎,我只是要粘貼,我已經得到工作的BitmapImage的轉換爲ByteArray
public static Byte[] ImageToByteArray(BitmapImage image)
{
using (MemoryStream ms = new MemoryStream())
{
WriteableBitmap btmMap = new WriteableBitmap
(image.PixelWidth, image.PixelHeight);
Extensions.SaveJpeg(btmMap, ms,
image.PixelWidth, image.PixelHeight, 0, 100);
return ms.ToArray();
}
}
感謝代碼很多!我曾嘗試使用流預先,但我用'DataReader'而不是'MemoryStream' :) – user1123530
你使用的是什麼版本的框架?我無法在BitmapImage中找到SetSource方法! – arturn