From: Rob L. <Rob...@no...> - 2004-04-16 07:15:14
|
Hi, > > I believe it should be: > > > > RGB(r,g,b) ((DWORD)(((BYTE)(r)|((WORD)(BYTE)(g)<<8))|(((DWORD)(BYTE)(b))<<16))) > I agree, > > Actually this should be sufficient: > > #define RGB(r,g,b) ((COLORREF) ((BYTE)(r) | ((BYTE)(g) << 8) | ((BYTE)(b) << 16))) I think shifting a byte 8 bits to the left leaves you with a byt containing only 0's, and the original value disappearing because it does not fit into a byte anymore. The same holds for the 16 bit shift. It may depend on the compiler what actually happens, but I think the cast to WORD or DWORD are probably best left in. (Personally I'd use DWORD for everything) Rob Lievaart. |