I have a monochrome watermark bitmap, which I'd like to render over
COLOR_WINDOW. How to calculate the color to render it?
I'd like it to be lighter than COLOR_WINDOW if the one is dark and I like it
to be more dark than COLOR_WINDOW if the one is light (for example, white).
Thank you, I'm really apreciating any suggestions.
dmitry
Here is a simple way. It doesn't maintain hue, but with a small
difference in color, that shouldn't be much of a problem.
/* Begin untested code */
COLORREF wmark, wind = GetSysColor(COLOR_WINDOW);
const int diff = 10, threshold = 500; /* out of 765 */
int r = GetRValue(wind);
int g = GetGValue(wind);
int b = GetBValue(wind);
int lightness = r + g + b;
if (lightness > threshold)
wmark = RGB(max(r-diff, 0), max(g-diff, 0), max(b-diff, 0));
else
wmark = RGB(min(r+diff, 255), min(g+diff, 255), min(b+diff), 0));
SetTextColor(wmark); /* Assumes COLOR_WINDOW is white */
SetBgColor(wind); /* in the bilevel bitmap */
StretchBlt...
--
Sev