开发者

MFC: Save from CImage to database as selected file-type

We have a requirement that a user can l开发者_如何学Coad 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::Save has two overloads. You could use

HRESULT Save(
   IStream* pStream,
   REFGUID guidFileType
) const throw();

to save the image to an IStream. You could write your own simple IStream implementation or could try to use the CreateStreamOnHGlobal function, which creates an IStream object on an HGLOBAL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜