Jump to content
  • Advertisement

Archived

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

Nullio

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.

If you intended to correct an error in the post then please contact us.

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

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!