Jump to content
  • Advertisement
Sign in to follow this  
amine137

pixel color depth scaling

This topic is 3656 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.

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

Sign me up!