Page 1 of 1

Lighter and Darker..

PostPosted: Oct 22, 2002 @ 4:00am
by brendan
If I have a 16 bit PIXEL consisting of

RRRRRGGGGGGBBBBB how can I make the current content lighter and darker, keeping the same "Hue", i.e a dark red to a light red, is there a simple bit shift that can be performed am using easyce, does it have anything built in?

-B

PostPosted: Oct 22, 2002 @ 4:27am
by superman
To make a color darker, decrease each value by the same value until it reaches zero.

ex.

red (in rgb format)
255, 0, 0

to make a slightly darker red, subtract 25 from each value unless that value is 0, and if the value is < 25, set it to zero.

result: a slightly darker red
230, 0, 0

Now an example with R, G, and B values:

light gray:
192, 192, 192

reduced by 64 on each value yields dark gray
128, 128, 128

By subtracting the same number from each color value, you effectively lower the luminance of the color. To make the color lighter, simply add the same number to each of the R, G, and B values.

PostPosted: Oct 22, 2002 @ 4:43am
by brendan
yep, I know that, I was hoping that there was a bit mask (somthing) etc that could be performed on it, otherwise I'll have to so some fancy shifting or splitting it up.....

PostPosted: Oct 22, 2002 @ 5:33am
by brendan

yeah

PostPosted: Oct 22, 2002 @ 5:52am
by golan_trevize_x
I don't think mine is any more efficient than that really. Basically reducing the value of the R, G and B separately then putting 'em back together.

A faster way might be to use a series of bitmasks which you prepare beforehand, like hardcoded or something, but it's obviously not as elegant.

PostPosted: Oct 22, 2002 @ 9:36am
by refractor

PostPosted: Oct 23, 2002 @ 10:05pm
by Dave H

Adding two colors?

PostPosted: Oct 26, 2002 @ 4:05pm
by Malmer

PostPosted: Oct 26, 2002 @ 5:12pm
by Dan East

PostPosted: Oct 26, 2002 @ 7:19pm
by Dave H

PostPosted: Oct 26, 2002 @ 7:50pm
by Digby