2

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.

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1
    CByteArray byteArr;

    //fullfill byteArr
    COleStreamFile stream;
    if(!stream.CreateMemoryStream(NULL))
    {
        return;
    }
    stream.Write(byteArr.GetData(), byteArr.GetSize());
    stream.SeekToBegin();
    m_pSnapShot.reset(::new Gdiplus::Image(stream.GetStream( )));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.