0

我正在尝试在Windows Phone 8BitmapImage上进行序列化,但与桌面 C# 应用程序相比,WP SDK 中似乎缺少很多库......

基本上我有一个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();
        }
    }
4

1 回答 1

3
public static BitmapImage ByteArraytoBitmap(Byte[] byteArray)
{
    MemoryStream stream = new MemoryStream(byteArray);
    BitmapImage bitmapImage = new BitmapImage();
    bitmapImage.SetSource(stream);
    return bitmapImage;
}
于 2013-07-20T13:40:05.657 回答