Jump to content
  • Advertisement

Archived

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

Muzlack

16Bit color 565

This topic is 5386 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

I've written an engine that uses 32 bit color. For maximum compatability, I'm trying to make a 16 bit color version. Using this macro, #define RGB16 (r, g, b) (((r&31)<<11) | ((g&63)<<5) | (b&31)) I get some odd effects. I happened to be using a background color of (R43 G1 B225) and it comes out as a red color. Any reasons why, perhaps? [edited by - Muzlack on September 21, 2003 3:27:28 PM]

Share this post


Link to post
Share on other sites
Advertisement
The and operations look strange to me. You cant just ignore the high bits. You probably wanna right shift the rgb values like this:

#define RGB16 (r, g, b) (((r>>3)<<11) | ((g>>2)<<5) | (b>>3))


[edited by - z80 on September 21, 2003 6:06:01 PM]

Share this post


Link to post
Share on other sites
You are masking off the least significants bits. You want the most significant bits because they contribute most to the colour.

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!