Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to calculate watermark color?

1 view
Skip to first unread message

Dmitry Nogin

unread,
Mar 10, 2005, 9:41:40 AM3/10/05
to
Hello,

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


Severian

unread,
Mar 10, 2005, 2:04:19 PM3/10/05
to

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

0 new messages