From: Timo Kunze on
Hi,

I use the following code to create an IPictureDisp object from a
16x16x32bpp icon:

PICTDESC picture = {0};
picture.cbSizeofstruct = sizeof(picture);
picture.icon.hicon = hIcon;
picture.picType = PICTYPE_ICON;
CComPtr<IPicture> pPicture = NULL;
OleCreatePictureIndirect(&picture, IID_IPicture, TRUE,
reinterpret_cast<LPVOID*>(&pPicture));

As a test, I write it to a file:
CComPtr<IStream> pStream = NULL;
SHCreateStreamOnFile(L"F:\\Test.ico", STGM_WRITE | STGM_SHARE_DENY_WRITE
| STGM_CREATE | STGM_DIRECT, &pStream);
LONG cbSize;
pPicture->SaveAsFile(pStream, TRUE, &cbSize);

I've checked the color depth of hIcon, it's 32 bpp. But the icon in the
Test.ico file has a color depth of 4bpp. Why?

Timo
--
www.TimoSoft-Software.de - Unicode controls for VB6
"Those who sacrifice freedom for safety deserve neither."
"Demokratie ist per Definition unsicher. Ihr Schutz entsteht aus der
Überzeugung, dass die demokratischen Kräfte überwiegen und sich – auf
demokratischem Wege – durchsetzen."
From: Snorik on
On 30 Sep., 00:16, Timo Kunze <TKunze71...(a)gmx.de> wrote:
> Hi,
>
> I use the following code to create an IPictureDisp object from a
> 16x16x32bpp icon:
>
> PICTDESC picture = {0};
> picture.cbSizeofstruct = sizeof(picture);
> picture.icon.hicon = hIcon;
> picture.picType = PICTYPE_ICON;
> CComPtr<IPicture> pPicture = NULL;
> OleCreatePictureIndirect(&picture, IID_IPicture, TRUE,
> reinterpret_cast<LPVOID*>(&pPicture));
>
> As a test, I write it to a file:
> CComPtr<IStream> pStream = NULL;
> SHCreateStreamOnFile(L"F:\\Test.ico", STGM_WRITE | STGM_SHARE_DENY_WRITE
> | STGM_CREATE | STGM_DIRECT, &pStream);
> LONG cbSize;
> pPicture->SaveAsFile(pStream, TRUE, &cbSize);
>
> I've checked the color depth of hIcon, it's 32 bpp. But the icon in the
> Test.ico file has a color depth of 4bpp. Why?

Did you check with this function:

IPicture::get_Type

what it actually returns?
From: Timo Kunze on
Snorik schrieb:
> Did you check with this function:
>
> IPicture::get_Type
>
> what it actually returns?
It returns PICTYPE_ICON as expected.

Timo
--
www.TimoSoft-Software.de - Unicode controls for VB6
"Those who sacrifice freedom for safety deserve neither."
"Demokratie ist per Definition unsicher. Ihr Schutz entsteht aus der
Überzeugung, dass die demokratischen Kräfte überwiegen und sich – auf
demokratischem Wege – durchsetzen."
From: Christian ASTOR on
On 30 sep, 00:16, Timo Kunze <TKunze71...(a)gmx.de> wrote:

> I've checked the color depth of hIcon, it's 32 bpp. But the icon in the
> Test.ico file has a color depth of 4bpp. Why?

Yes, it seems to force to 4 bpp in BITMAPINFOHEADER
To convert from HICON to ICO file, I use the standard way with .ICO
file structures (ICONDIR, ICONDIRENTRY, BITMAPINFOHEADER, XOR bits,
AND bits)
From: Timo Kunze on
The whole 32bpp support of GDI seems to be crappy. Here's what I'm
trying to do:
I'm writing an image list ActiveX control for VB6. The image list
control that comes with VB6, doesn't support 32bpp icons. Also I don't
want to use comctl32.ocx or mscomctl.ocx just for one control.
Of course I somehow have to persist the icons into a property bag, so
that icons can be inserted at design time. I planned to call
ImageList_GetIcon for each icon, create an IPictureDisp object for it
and persist this object. This would have been the easiest way, but of
course this doesn't work as long as OleCreatePictureIndirect is broken.
Today I've found a "working" way to persist the icons: I store the DIB
bits of the icon's color bitmap and mask bitmap as byte arrays. To
restore the icon, I create bitmaps from the data stored in these arrays
and call ImageList_Add.
So far so good...

Just when I thought the beast is finally working as expected, I've
detected, that the images get darker over time. Obviously my
ImageList_GetIcon, GetDIBits, CreateDIBitmap and ImageList_Add chain
isn't lossless and something is telling me that it's not my code's fault...
BTW, the image list control of vbAccelerator has the same problem of
images getting darker over time.

/me shoots himself

Timo
--
www.TimoSoft-Software.de - Unicode controls for VB6
"Those who sacrifice freedom for safety deserve neither."
"Demokratie ist per Definition unsicher. Ihr Schutz entsteht aus der
Überzeugung, dass die demokratischen Kräfte überwiegen und sich – auf
demokratischem Wege – durchsetzen."
 |  Next  |  Last
Pages: 1 2
Prev: HOWTO: formatting memory cards
Next: Hooking functions