I got this code to convert WriteableBitmap
to byte array in my previous question
Converting WriteableBitmap to Byte array - Windows phone 8.1 - Silverlight
public static byte[] ConvertToByteArray(WriteableBitmap writeableBitmap)
{
using (var ms = new MemoryStream())
{
writeableBitmap.SaveJpeg(ms,
writeableBitmap.PixelWidth, writeableBitmap.PixelHeight, 0, 100);
return ms.ToArray();
}
}
This code works but it returns arrays of different lengths every time. Is it possible to get the array of same size each time? The writeableBitmaps
that it gets as parameter are always of same size.