0

So far I have:

using (MemoryStream ms = new MemoryStream(imageData))
{
     Bitmap img = (Bitmap)Image.FromStream(ms);
}

And then I would imagine I would be able to get a BitmapSource from img somehow? If this is totally wrong please feel free to correct me.

User1
  • 17,202
  • 13
  • 104
  • 183

2 Answers2

0

Try using BitmapSource.Create(). But you need to create pallete first:

var colors = new List<Color>();
colors.Add(Colors.Red);
colors.Add(Colors.Blue);
colors.Add(Colors.Green);
var palette = new BitmapPalette(colors);
dee-see
  • 22,825
  • 5
  • 58
  • 88
Eldar Dordzhiev
  • 5,055
  • 2
  • 20
  • 26
0

Got the easiest solution:

using (MemoryStream ms = new MemoryStream(imageData))
{
    BitmapDecoder bitmapDecoder = BitmapDecoder.Create(ms, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);
    BitmapSource photo = new WriteableBitmap(bitmapDecoder.Frames.Single());
}

Haven't tested it yet but my code was taken from: Here

User1
  • 17,202
  • 13
  • 104
  • 183