Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting PNG images from Delphi 2009 imagelist

The TImageList of Delphi 2009 has support for PNG images by adding them in the imagelist editor. Is there any way to extract a TPngImage from a TImagelist and preserving the alpha channel?

What I want to do is actually to extract the images from one TImageList, make a disabled version of them and then add them to another TImageList. During this operation I would of course like to preserve the alpha channel of the PNG images.

like image 588
ajob Avatar asked Dec 13 '25 06:12

ajob


1 Answers

I did something like this with Delphi 2006.

TImageList contains a protected method GetImages. It can be accessed using the "protected bug"

type
  TGetImageImageList = class (TImageList) // Please use a better name!
  end;

You can cast the imagelist to the TGetImageImageList to get to the GetImages.

begin
  TGetImageList(ImageList).GetImages(index, bitmap, mask);
end;

Bitmap contains the bitmap and mask is a black and white bitmap that determines the transparant sections.

You now can change the bitmap and store it using:

function Add(Image, Mask: TBitmap): Integer;

I hope this gives you enough pointers to explore further.

like image 121
Toon Krijthe Avatar answered Dec 15 '25 16:12

Toon Krijthe