Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2019-05

TBitBtn image, how to make background transparent?

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bo Berglund

I am trying to make a bitmap image for a TBitBtn button such that the background of the image will be transpoarent and therefore the button color will be visible.

But I don't succeed with this, the background I use for the image is visible on the button.
Even if I set the same color as the buttonface to the background it becomes visible on the button because the button itself has gadient color....
So not the same color at the top of the button and at the bottom.

I was under the impression that button images use the color of pixel (1, 1) as the define for the transparent color, so I have the complete border set to the same background color.
Not working....

Or is a specific color defined as the transparent color, if so what is this color? (RGB please)

What can I do to use glyphs on a TBitButton?

Bo Berglund Developer in Sweden

Reply by email

Ondrej Pokorny
to Bo Berglund
Bo Berglund wrote
I am trying to make a bitmap image for a TBitBtn button such that the background of the image will be transpoarent and therefore the button color will be visible.

What OS and WidgetSet? If you are on win32 - AFAIR a PNG works just fine.

Ondrej

Reply by email

Bo Berglund
to Ondrej Pokorny
Ondrej Pokorny wrote 7 lines
On 13.05.2019 22:36, Bo Berglund via lazarus wrote: > I am trying to make a bitmap image for a TBitBtn button such that the > background of the image will be transpoarent and therefore the button > color will be visible. What OS and WidgetSet? If you are on win32 - AFAIR a PNG works just fine.

Windows 7 x64, Lazarus 2.0.0 32 bit, fpc 3.0.4

I have tried creating a png image (24x24 pixels) with a gray background equal to the shade at the bottom of the TBitBtn. When I assign this image as the glyph of the TBitBtn I can see the image square against the button since the button's gray color is whiting out towards the top.
So my gray shade is not transparent...

----- BUT WAIT A MINUTE! -------

Even as the button appears with the colored square inside the Lazarus IDE the background actually disappears (becomes transparent) when I compile the application and run it!
So it seems like the form is displaying the button in a different way in the IDE from when the program is running.

I did not know this and I had a number of other items I was coding on so I did not test it actually running, believing that what I see in the IDE is what I get when running.

Issue resolved.

Bo Berglund Developer in Sweden

Reply by email

Ondrej Pokorny
to Bo Berglund
Bo Berglund wrote 6 lines
I have tried creating a png image (24x24 pixels) with a gray background equal to the shade at the bottom of the TBitBtn. When I assign this image as the glyph of the TBitBtn I can see the image square against the button since the button's gray color is whiting out towards the top. So my gray shade is not transparent...

PNG supports alpha-channel - use it.

Ondrej

Reply by email