What is this doing?
(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?
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
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
Popular Topics
Advertisement