Josh Josh - 1 year ago 320
C++ Question

Gdiplus::Image from byte array

I'm executing dcraw and using an anonymous pipe to pipe it to a char array.

My question is how can I create a

object from a char array containing the jpeg image? Without writing and reading it from the disk.

Answer Source

You can create a Gdiplus::Bitmap from an IStream source. There are built-in Windows APIs that can do this for you - see CreateStreamOnHGlobal. Another way is to write your own class that implements IStream.

Here is an example using CreateStreamOnHGlobal to load PNG resources from memory.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download