I have seen a couple of examples, but nothing helped me so far with this issue.
I have an image in byte[] which size must be reduced to under 2 MB. I tried a couple of things, but nothing helped so far.
I used the following code which could be found at many questions like this:
public static byte[] Compress(byte[] data)
{
MemoryStream output = new MemoryStream();
using (DeflateStream dstream = new DeflateStream(output, CompressionLevel.Optimal))
{
dstream.Write(data, 0, data.Length);
}
return output.ToArray();
}
This does reduce the size of the image, but not below 2 MB and I have no idea how to state that here. Other examples were focused on saving the image on the phone with reduced size, but my image should remain in byte[]. This question thus does not help.
I hope someone can help.