#### Archived

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

# What is this doing?

This topic is 6074 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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
A division of DLC Multimedia

Resist Windows XP''s Invasive Production Activation Technology!

"gitty up" -- Kramer

##### Share on other sites
Ya ok, but that doesn''t explain what it''s doing

##### 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.

1. 1
2. 2
3. 3
4. 4
Rutin
18
5. 5

• 12
• 9
• 12
• 37
• 12
• ### Forum Statistics

• Total Topics
631415
• Total Posts
2999964
×