Which line is throwing the exception? The new MemoryStream(...)
? or the Image.FromStream(...)
? And what is the byteArrayIn
? Is it a byte[]
? I only ask because of the comment "And none of value in it is not greater than 255" - which of course is automatic for a byte[]
.
As a more obvious question: does the binary actually contain an image in a sensible format?
For example, the following (although not great code) works fine:
byte[] data = File.ReadAllBytes(@"d:\extn.png"); // not a good idea...
MemoryStream ms = new MemoryStream(data);
Image img = Image.FromStream(ms);
Console.WriteLine(img.Width);
Console.WriteLine(img.Height);