Lazarus
Programming => Graphics => Graphics and Multimedia => BGRABitmap and LazPaint => Topic started by: Dibo on November 01, 2011, 07:18:41 pm
-
Hi,
I have TPaintBox and TBGRABitmap with some logo in PNG format. This logo is only in one color (e.g. white). Can I draw it so that it is visible on the light and dark background? Look at attachments. This is only fake demo with TLabel as Logo. If user have dark system theme then logo should be white, if he have light theme then it should be dark. Is it possible?
Regards
-
In unit Graphics is function
function InvertColor(AColor: TColor): TColor;
if you need to invert Label.Font.Color
You will probably need to detect whether the theme is light or dark.
I would take the background color (probably clForm) and convert it to RGB:
function ColorToRGB(Color: TColor): Longint;
Separete it to R, G and B and make R+G+B. You will get result from 0 to (3*255).
High result = light theme, low result = dark theme.
-
Thanks, this is what I needed.
-
By the way, if you want to invert a bitmap, you can call "Negative" function. But if you draw the text, you can compute the best color like Blaazen told you.