tags:

views:

2522

answers:

4

I'm using Delphi 2007. How can I put a GIF/PNG image on a BitBtn component? (Preferably, with alpha transparency supported)

+2  A: 

Use a graphics program like Photoshop (or something less expensive) to convert the images to bitmaps. BitBtns don't accept GIF or PNG images.

Kluge
But then transparency becomes an issue.
delphist
From memory, Delphi had a little trick where it considered one of the corner pixels (top-left? bottom-left?) to be the "transparent" colour. Provided you leave that pixel as the colour you want to be transparent it should work, even for BMPs.
Matt Hamilton
It's the bottom left pixel, but it's colour-key transparency only. If you want alpha-blended transparency, you need to use PNG in Delphi 2009.
Tim Knipe
For conversion, you can use Paint.NET or IrfanView. Both are free.
gabr
Weird - I see a lot of replies talking about alpha transparency, but I didn't get that from his question. He mentions GIF too - does GIF have an alpha channel? I don't remember.
Matt Hamilton
+1  A: 

PNG support is only fully supported by Delphi 2009. There is a freeware package (licensed as MPL 1.1) named GraphicEx which will allow you to load the images at design time/runtime, but you will not get the alpha blended transparency on the button in Delphi 2007.

skamradt
+3  A: 

PngComponents pack has a component named PngBitBtn wich can display correctly PNG's with alpha transparency. They are somewhat old, but they can be installed under Delphi 2007 with a little work.

atika
A: 

PNGimage, which is included in Delphi 2009k, should do the job. If we can find it.

Henrik R Clausen