Josh Josh - 3 months ago 49
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

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

Answer

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.