I\'m using the following code trying to convert my BitmapImage to a byte[] so I can save it in my MS SQL Database.
public static byte[] BufferFromImage(Bi
I finally managed to get it working:
public static byte[] BufferFromImage(BitmapImage img)
{
byte[] result = null;
if (img != null)
{
using(MemoryStream memStream = new MemoryStream())
{
JpegBitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(img));
encoder.Save(memStream);
result = memStream.ToArray();
}
}
return result;
}