Archived

This topic is now archived and is closed to further replies.

Nullio

What is this doing?

Recommended Posts

(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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites