Loading bytes manually into a Bitmap/Image object. (i.e. How to cast web downloaded PNG image in
Hi,
I've got a byte[] array containing a PNG file downloaded over the web.
How do I dump it all into a Bitmap or Image object in CF 1.0?
I am still researching, and it looks like I am missing something that is probably obvious, or that there is a workaround I must do...
Thanks,
Mark Rejhon
I could get a Stream and pass it onto Bitmap, but my software has built in a web caching system, and byte[] arrays are used to store the cached web data. So this is why I need to be able to render a Bitmap or Image from a byte[] array.
Is there an easy way to turn a byte[] array into a Stream object, without having to write it to disk?
I answered my own question. Yes, it is possible, and really easy after all. Use the MemoryStream object:
MemoryStream s =
new MemoryStream(byteArray, 0, byteArray.Length);
Bitmap image = new Bitmap(s);