Make button glyphs have transparent background in delphi 7?

I have four TSpeedButton objects, each with a BMP file assigned as a symbol for the button image. For some reason, delphi decided that two button images should have a transparent background and two should have a white background. I created the bitmaps myself, so they are all kept at the same color depth and use a white background (not some shade of almost white) for the background and have a background color in all four corner pixels of the image.

Why do some of the glyph images appear with a transparent background and some do not? What is the criterion for background transparency? How can I make my button images have transparent backgrounds instead of half of them having transparent backgrounds?


source to share

2 answers

Ken's comment

Delphi's glyph processing uses the pixel in the lower left corner to define the transparent color. All pixels corresponding to this color should be shown as transparent. Is the bottom-left pixel color consistent across all glyphs and matches the areas you want to be transparent? (Without images, it's hard to tell what the problem is, but I thought I'd post this as an opportunity for research.)

the correct answer appeared (sorry, I cannot accept the comment as the correct answer!). The image I used had a drop shadow reaching the bottom left corner, so it was almost white in that corner and even white in all other corners.



I had a similar problem with D5 and included a fix for this since I didn't find out why this was happening.

Set the image size to be equal to the Row above the actual image / glyph. This will cause the image to write from the top-left position and stop before the last line. This will force the use of an opaque color, and the extra line below the image will not be visually noticeable.



All Articles