Color Brightness
-
I'm looking for a simple way to increase or decrease the brightness of a specified color, for making a highlight and shadow color to match the given one. Any idea will be muchly appreciated. Happy programming!!
-
I'm looking for a simple way to increase or decrease the brightness of a specified color, for making a highlight and shadow color to match the given one. Any idea will be muchly appreciated. Happy programming!!
-
I'm looking for a simple way to increase or decrease the brightness of a specified color, for making a highlight and shadow color to match the given one. Any idea will be muchly appreciated. Happy programming!!
My post at CodeGuru Forums[^] : A simple way to adjust the brightness of a color is to adjust a constant value of red, green, and blue in a color. Here is a function for this.
COLORREF Brighten(COLORREF cr, int val){
BYTE r,g,b;
r=(BYTE)min(255,max(0,GetRValue(cr)+val));
g=(BYTE)min(255,max(0,GetGValue(cr)+val));
b=(BYTE)min(255,max(0,GetBValue(cr)+val));
return RGB(r,g,b);
}A positive value for val brightens the color, and a negative value for val darkens the color. Be sure the val parameter is within the range -255 to 255. Peter O.