What is this doing?

Started by
2 comments, last by Nullio 22 years, 5 months ago
(short) RGB = ((R & 248) << 8) + ((G & 252) << 3) + ((B & 248) >> 3); ok, how does this work??? I know it converts from 24 bit -> 16 bit but how??? and the "&"''s are AND right?
Advertisement
quote:Original post by Nullio
(short) RGB = ((R & 248) << 8) + ((G & 252) << 3) + ((B & 248) >> 3);

ok, how does this work??? I know it converts from 24 bit -> 16 bit but how??? and the "&"''s are AND right?


Actually, they are Bitwise ANDs. In other words, they operate on the bit level. If you want ot understand a bit more, there''s an article called Bitwise Operations in C that you can check to figure it out...

Also one last thing, the numbers after the "&" signs are in Hex.



"And that''s the bottom line cause I said so!"

Cyberdrek
Headhunter Soft
A division of DLC Multimedia

Resist Windows XP''s Invasive Production Activation Technology!

"gitty up" -- Kramer
[Cyberdrek | ]
Ya ok, but that doesn''t explain what it''s doing
in short: it discards the least significant few bits of each channel, then shifts it into the right place in each, then adds them. Those addition operators serve the purpose of bitwise OR.

This topic is closed to new replies.

Advertisement