We have a requirement that a user can load any standard image into a dialog, the image is displayed, and the image saved as a specific format (JPG) in a database. It seems CImage is the class to be using since it can load and save BMP/GIF/JPG/PNG. But is there an easy way to save the JPG as a BLOB in the database without calling CImage::Save and then loading the file to memory – we don’t want to save the file even temporarily.
Any ideas?
CImage::Savehas two overloads. You could useto save the image to an
IStream. You could write your own simpleIStreamimplementation or could try to use theCreateStreamOnHGlobalfunction, which creates anIStreamobject on anHGLOBAL.