Code and Coffee


Quick Snippets: Lighten a Color

Posted on October 31, 2006, under Development.

I have been busy with work, and my side projects. I am working hard on getting a new version of NetGrid out the door. It will be the first major update in years, and it will include great features… just wait :)

Here is a quick snippet on how to lighten a color with C++, actually needed it for NetGrid. Enjoy, and don’t eat too much candy.

[cpp]

// Lighten a color
COLORREF LightenColor(COLORREF cColor, double dFactor)
{
return RGB(
dFactor * 255 + (1.0 - dFactor) * GetRValue(cColor),
dFactor * 255 + (1.0 - dFactor) * GetGValue(cColor),
dFactor * 255 + (1.0 - dFactor) * GetBValue(cColor)) ;
}
[/cpp]

Popularity: 3% [?]