[Lazarus] Converting Icon from Windows handle to TBitmap with transparency

cobines cobines at gmail.com
Fri Jul 15 01:15:27 CEST 2011


2011/7/15 cobines <cobines at gmail.com>:
> Also a question:
> Why TIcon always has Masked=True?
>
> Icons with alpha channel don't work properly with TIcon and they don't
> use Mask. Is support for alpha channel icons simply not implemented?

More question related to this.

In

function TWin32WidgetSet.RawImage_FromBitmap(out ARawImage: TRawImage;
ABitmap, AMask: HBITMAP; ARect: PRect = nil): Boolean;

there is code:

  if ASize < SizeOf(WinDIB) then
    ARawImage.Description.AlphaPrec := 0;

It seems that TIconInfo.HBITMAP handle (which in my case is a default
system folder icon) has not been created with CreateDIBSection
therefore GetObject returns plain HBITMAP and not DIBSECTION and the
code above disables alpha channel.

However, when I remove that code icons with alpha channel are
displayed properly. AlphaPrec=8, pixelFormat is pf32bit. Masked=True
but that doesn't seem to matter.

The code was added in

http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=rev&root=lazarus&revision=13314

and fixed bug

http://bugs.freepascal.org/view.php?id=10299

I don't understand why it says:

"if it is not DIB then alpha in bitmaps is not supported => use 0 alpha prec"

since it seems HICON bitmaps is not DIB but it has alpha channel.

--
cobines




More information about the Lazarus mailing list