Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transparent PNG image (with TImageList) in a TMainMenu

I want to load a PNG with transparent background in a TImageList and use it in a TMainMenu (via TAction).
However, in Delphi the background is just black.

This guy says it worked for him, but with a button instead of a main menu.

My setup:

  • My image is 8 bit per color plus 8 bit for transparency channel (I have tried also with 1 bit for transparency but still doesn't work). The image looks just fine in any other program.
  • Delphi XE.
  • In TImageList's editor, the 'transparent color' and 'Fill color' are set to 'Default' and are disabled.
like image 690
Server Overflow Avatar asked Aug 13 '11 13:08

Server Overflow


People also ask

Can PNG have transparent pixels?

Transparency makes it possible to create nonrectangular images for the web. Background transparency, supported by the GIF and PNG formats, preserves transparent pixels in the image and allows the background of the web page to show through the transparent areas of your image.

Can PNG have transparent background?

These features make PNG an ideal file type to use for logos, icons, and digital art. Most importantly, PNG is a crowd favorite because it supports transparent backgrounds. Colors (including white) fill all the pixels in a regular image.


1 Answers

There's no reason to backup whole DFM file.

Before doing something to your ImageList you should export your images: click the "Export" button in the image list editor and it will save all images to a single .BMP file.

After changing properties: ColorDepth = cd32Bit, DrawingStyle = dsTransparent

You should click "Add" button and select the file you previously exported. Then, images will be drawn with transparency in the menu and toolbars (on D2010 at least)... No need to use 3rd party components.

like image 109
djsoft Avatar answered Sep 16 '22 15:09

djsoft