Saving Bitmap from Clipboard to File Error
Posted
by Vanwaril
on Stack Overflow
See other posts from Stack Overflow
or by Vanwaril
Published on 2010-04-04T07:10:55Z
Indexed on
2010/04/04
7:13 UTC
Read the original article
Hit count: 226
I'm using OLEDropTarget to get dropped content. It works fine with text. However, I'm not able to figure out how to get bitmaps from CF_BITMAP type data objects and save them to file. My code:
HGLOBAL hg = pDataObject->GetGlobalData(CF_BITMAP);
if (NULL == hg)
{
return FALSE;
}
HBITMAP pData = (HBITMAP)GlobalLock(hg);
if(pData == NULL)
return false;
HBITMAP bmp;
::GetObject(pData,sizeof(HBITMAP),&bmp);
CImage cnn;
cnn.Attach(bmp);
cnn.Save(L"here.bmp",Gdiplus::ImageFormatBMP);
I get an error on the Attach, but when debugging I noticed that the GetObject doesn't make a copy into the second HBITMAP.
© Stack Overflow or respective owner