I'm using the follwing macro function:

#define MK_RGB5651(R,G,B,R1,B1,G1) \ (__int32) (
((MAX(0,MIN(255, R1)) << 0x18) & 0xf8000000) | \
((MAX(0,MIN(255, G1)) << 0x13) & 0x07e00000) | \
((MAX(0,MIN(255, B1)) << 0xd) & 0x001f0000) | \
((MAX(0,MIN(255, R)) << 8) & 0x0000f800) | \
((MAX(0,MIN(255, G)) << 3) & 0x000007e0) | \
((MAX(0,MIN(255, B)) >> 3) & 0x0000001f) )
R,G,B,R1,B1,G1 are int type.

I dunno why the 2 least significant bit of the 32-bit output are always 1s
(no matter what my input is).
Also, I could not ust decimal 24 instead of hex 0x18 (the same holds for
0x13 and 0xd).
Could someone give me pointers to these two problems?

Re: macro funtion error by Bruce

Bruce
Wed Jan 21 11:09:59 CST 2004

Check your shifting.
> ((MAX(0,MIN(255, G)) << 5) & 0x000007e0) | \
> ((MAX(0,MIN(255, B))) & 0x0000001f) )

I did not check the rest, that is up to you.

Why do you say that you can't use the decimal values?

--
Bruce Eitman (eMVP)
Senior Engineer
Accelent Systems Inc.
www.accelent.com





Re: macro funtion error by Leesei

Leesei
Sat Jan 24 02:43:21 CST 2004

Thanks for your reply.
I'll have a check on it.

When I use << 13, it shifted 18 bits, taking the 13 as hex value. I wonder
why.


"Bruce Eitman (eMVP)" <beitmannospam@accelentnospam.com> ¼¶¼g©ó¶l¥ó·s»D
:OetEoFE4DHA.1644@TK2MSFTNGP10.phx.gbl...
Check your shifting.
> ((MAX(0,MIN(255, G)) << 5) & 0x000007e0) | \
> ((MAX(0,MIN(255, B))) & 0x0000001f) )

I did not check the rest, that is up to you.

Why do you say that you can't use the decimal values?

--
Bruce Eitman (eMVP)
Senior Engineer
Accelent Systems Inc.
www.accelent.com