Timo Kunze
2005-02-14 19:02:38 UTC
Hi,
I'm using the following code to retrieve a DIB (CF_DIB) from an
IDataObject and to convert it into an IPictureDisp object, that's stored
in a VARIANT:
LPBITMAPINFO pBMPInfo = (LPBITMAPINFO) ::GlobalLock(storageMedium.hGlobal);
// point to the DIB bits after the BITMAPINFO struct
LPVOID pDIBBits = (LPVOID) (pBMPInfo + 1);
PICTDESC picture = {0};
picture.cbSizeofstruct = sizeof(picture);
picture.bmp.hbitmap = ::CreateDIBitmap(::GetDC(NULL),
&pBMPInfo->bmiHeader, CBM_INIT, pDIBBits, pBMPInfo, DIB_RGB_COLORS);
picture.bmp.hpal = GetPaletteFromDataObject(properties.pDataObject);
picture.picType = PICTYPE_BITMAP;
// now create an IPictureDisp object out of the bitmap
::OleCreatePictureIndirect(&picture, IID_IPictureDisp, TRUE, (LPVOID*)
&pData->pdispVal);
pData->vt = VT_DISPATCH;
::GlobalUnlock(storageMedium.hGlobal);
In VB6, I then assign the retrieved picture to a Form's picture property
to display it. The whole thing gets executed if I drag a picture from a
web browser (e. g. Firefox) onto my ActiveX control.
The picture gets shown, but the colors are wrong (see the end of this
post for a sample). But if I drag the picture onto the form itself, so
VB's built-in DataObject class gets used, the colors are correct. So the
failure must be in my code. I use similiar code for the CF_BITMAP
format, which works just fine. So the error must be within the following
lines:
LPBITMAPINFO pBMPInfo = (LPBITMAPINFO) ::GlobalLock(storageMedium.hGlobal);
// point to the DIB bits after the BITMAPINFO struct
LPVOID pDIBBits = (LPVOID) (pBMPInfo + 1);
picture.bmp.hbitmap = ::CreateDIBitmap(::GetDC(NULL),
&pBMPInfo->bmiHeader, CBM_INIT, pDIBBits, pBMPInfo, DIB_RGB_COLORS);
I've no clue what's wrong here. Does anyone know what's causing the
wrong colors?
Here're 2 sample pictures. The 1st one is how it looks in the browser,
the 2nd is what my code produces:
Loading Image...
Loading Image...
Timo
I'm using the following code to retrieve a DIB (CF_DIB) from an
IDataObject and to convert it into an IPictureDisp object, that's stored
in a VARIANT:
LPBITMAPINFO pBMPInfo = (LPBITMAPINFO) ::GlobalLock(storageMedium.hGlobal);
// point to the DIB bits after the BITMAPINFO struct
LPVOID pDIBBits = (LPVOID) (pBMPInfo + 1);
PICTDESC picture = {0};
picture.cbSizeofstruct = sizeof(picture);
picture.bmp.hbitmap = ::CreateDIBitmap(::GetDC(NULL),
&pBMPInfo->bmiHeader, CBM_INIT, pDIBBits, pBMPInfo, DIB_RGB_COLORS);
picture.bmp.hpal = GetPaletteFromDataObject(properties.pDataObject);
picture.picType = PICTYPE_BITMAP;
// now create an IPictureDisp object out of the bitmap
::OleCreatePictureIndirect(&picture, IID_IPictureDisp, TRUE, (LPVOID*)
&pData->pdispVal);
pData->vt = VT_DISPATCH;
::GlobalUnlock(storageMedium.hGlobal);
In VB6, I then assign the retrieved picture to a Form's picture property
to display it. The whole thing gets executed if I drag a picture from a
web browser (e. g. Firefox) onto my ActiveX control.
The picture gets shown, but the colors are wrong (see the end of this
post for a sample). But if I drag the picture onto the form itself, so
VB's built-in DataObject class gets used, the colors are correct. So the
failure must be in my code. I use similiar code for the CF_BITMAP
format, which works just fine. So the error must be within the following
lines:
LPBITMAPINFO pBMPInfo = (LPBITMAPINFO) ::GlobalLock(storageMedium.hGlobal);
// point to the DIB bits after the BITMAPINFO struct
LPVOID pDIBBits = (LPVOID) (pBMPInfo + 1);
picture.bmp.hbitmap = ::CreateDIBitmap(::GetDC(NULL),
&pBMPInfo->bmiHeader, CBM_INIT, pDIBBits, pBMPInfo, DIB_RGB_COLORS);
I've no clue what's wrong here. Does anyone know what's causing the
wrong colors?
Here're 2 sample pictures. The 1st one is how it looks in the browser,
the 2nd is what my code produces:
Loading Image...
Loading Image...
Timo
--
www.TimoSoft-Software.de - the home of ExplorerTreeView
Stop software patents!
www.TimoSoft-Software.de - the home of ExplorerTreeView
Stop software patents!