I have a HENHMETAFILE. I want to construct a JPEG with given width and height out of it, and send it to some server. For doing this I need to get a bytestream of the JPEG, and the size of the stream in bytes.
Currently I do this with CImage::Save to save the meta file to disk as JPEG, then read the created file to get my bytestream, and delete the JPEG afterwards. This obviously is quite an awkward approach.
Does anyone have a hint how to skip the process of storing the image to disk? I would prefer to not use external libraries if possible. I am using MSVC++ 2010.
CImage::Save() has a second overload for saving to an IStream.
This article shows how to use in memory image compression:
http://www.codeproject.com/KB/GDI-plus/MemImage.aspx
It uses the GDI+ Image instead, but should be enough to get you started.