If you change desktop background to a lighter color, Windows autometically changes icon font color to black. If you change it to a darker color, it changes the font color to white.
How it detects which color is lighter and which color is darker ?
Printable View
If you change desktop background to a lighter color, Windows autometically changes icon font color to black. If you change it to a darker color, it changes the font color to white.
How it detects which color is lighter and which color is darker ?
Colours are stored simply as integer values. You can either test if the sum of all colour parts (the whole number, in other words) is less than a threshold value, or you can break it in to its RGB components and test each of those individually.
I think testing the "hue" of the color is easier!
Saturation, rather. But colours on Windows are stored as RGB, so it's less efficient to convert to an HSB value first ;)
To split a compound DWORD RGB value:
Code:red = rgbValue & 0xff
green = (rgbValue & 0xff00) \ 0xff
blue = rgbValue \ 0xff00
Yes. I know about RGB extraction.
But I guess testing the sum of all colour parts will not help here.
For example, change desktop color to following RGB values:
RGB(100,255,100) => Text color changes to Black
RGB(255,100,100) => Text color changes to Black
RGB(100,100,255) => Text color changes to White
There must be some other algo that checks which color is darker to human eye.
...And how do you check hue/saturation through VB code ? (.NET has them in COLOR sructure, but what is in VB ?)
Well, you could test based upon individual thresholds for red green and blue.
This page illustrates how to convert from RGB to HSB.
Great !!! Thanks. :thumb:
I guess Luminance will do it. It will be easier to check.
btw, Lum and Brightness are same. Aren't they ?
One and, yes.
Thanks ! :)