Hello everyone.
I want to convert an icon retrieved by Windows API to a TBitmap saving transparency. As I understand transparency can be achieved by:
- using an additional Mask bitmap
- using 32bpp TBitmap with alpha channel
Having the handle to an icon from WINAPI, I convert it to TBitmap the following way:
function IconToBitmap(h: HICON): TBitmap;
var
icon: TIcon;
begin
icon := TIcon.Create;
icon.Handle := h;
Result := TBitmap.Create;
Result.Assign(icon);
icon.Free;
end;But this does not preserve transparency. I have to add:
Result.Mask(Result.TransparentColor);Is this the correct way?
Why Icon does not automatically have a Mask? It does have TransparentMode and TransparentColor correctly assigned. TransparentColor is copied to TBitmap but the Mask is not copied or not automatically created.
