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

[304 byte] By [MarkRejhon] at [2007-12-16]
# 1
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?

MarkRejhon at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 2
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);

MarkRejhon at 2007-9-9 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...