0

I'm trying to get BitmapImage serialization working on Windows Phone 8, but it seems that a lot of libraries are missing from the WP SDK compared to desktop C# apps...

Basically I've got a Byte array that I need to parse into a BitmapImage for displaying, however nothing I could find on the web works... Any help is much appreciated! :)

Since StackOverflow's algorithm thinks this question is too trivial, I'm just gonna paste the code that I've got working to convert the BitmapImage to a 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();
        }
    }
user1123530
  • 561
  • 3
  • 7
  • 17

1 Answers1

3
public static BitmapImage ByteArraytoBitmap(Byte[] byteArray)
{
    MemoryStream stream = new MemoryStream(byteArray);
    BitmapImage bitmapImage = new BitmapImage();
    bitmapImage.SetSource(stream);
    return bitmapImage;
}
anderZubi
  • 6,414
  • 5
  • 37
  • 67