How do I convert a FILE* to an IStream!
Using GDI+, I want to save an HBITMAP to a disk file as JPG.
However, I am doing this within a legacy function that provides an already opened FILE* as a parameter.
I have found nothing in the docs.
static Bool sys_ImageToFileJPEG (HBITMAP hImage, FILE* pFile)
{
Bool fRet = FALSE;
if (hImage && pFile)
{
Gdiplus::Bitmap image ((HBITMAP)hImage, (HPALETTE)0);
if (image.GetLastStatus() == Gdiplus::Ok)
{
CLSID encoderClsid;
wimg_GetEncoderClsid (L"image/jpg", encoderClsid);
// will not work - Save() wants an IStream!!!
Gdiplus::Status hr = image.Save (pFile, &encoderClsid);
if (Gdiplus::Ok == hr)
{
fRet = true;
}
}
}
return (fRet);
}