Jump to content
  • Advertisement


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


DirectDraw 16-bit

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

Hello, I was just in need of some code to extract individual components out of a 16-bit colour. I can write to a 16-bit DirectDraw surface, and I can read from it. But when I read a certain 16-bit pixel into a 16-bit variable, how do I extract the Red, Green and Blue components that make up that colour? I know that this is a simple question of logic and the howtos of programming, but I just can''t do it right. Any help would be appreciated, Thank you very much,

Share this post

Link to post
Share on other sites

#define R555(color) (color >> 10)
#define G555(color) ((color & 0x3E0) >> 5)
#define B555(color) (color & 0x1F)

pixelformat: 5.6.5
#define R565(color) (color >> 11)
#define G565(color) ((color & 0x7E0) >> 6)
#define B565(color) (color & 0x1F)

hope that helps

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!