Reputation: 107
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.
Upvotes: 0
Views: 218
Reputation: 100545
Jpeg is compressed image format so unless your input has identical content all the time you'll get different length in byte (even for same size of an image).
Your options:
Upvotes: 1