Jump to content
  • Advertisement
Sign in to follow this  
amine137

pixel color depth scaling

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

Hi All, I am trying to write a C++ code that would convert a 24 bit RGB into a 16 bit Grayscale. Does anybody knows how to do that? Thank you

Share this post


Link to post
Share on other sites
Advertisement
What you can first to is find the brightness of the color by using the formula:

Y = 0.299R + 0.587G + 0.114B

You then normalize this value into the [0,1] range, and multiply the result by 65535 (which is the maximum value of an unsigned 16-bit number).

Share this post


Link to post
Share on other sites
Sign in to follow this  

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