Archived

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

Taking 16bit to 24bit

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

For some reason. When I use
  
unsigned char byBlue = (wValue & m_ddpxfColor.dwBBitMask)* 255/m_ddpxfColor.dwBBitMask);
unsigned char byGreen = (wValue & m_ddpxfColor.dwGBitMask)* 255/m_ddpxfColor.dwGBitMask);
unsigned char byRed = (wValue & m_ddpxfColor.dwRBitMask)* 255/m_ddpxfColor.dwRBitMask);
  
To convert my colors back to 24 bit when I convert them back. They appear darker. Is there a flaw in my math I don''t see?

Share this post


Link to post
Share on other sites
thats because you dont shift

255/m_ddpxfColor.dwRBitMask...
lets say m_ddpxfColor.dwRBitMask = 0xf800,
than thats 255/0xf800 or 255/(more than 255) and thats 0.
(integer division).

just think about it again, and maybe youll see what youre doing wrong.



--- foobar
We push more polygons before breakfast than most people do in a day

Share this post


Link to post
Share on other sites
You lose to low order 3-bits when you convert *TO* 16-bit colors. Typical format: ARRRRRGGGGGBBBBB. Thus a full intensity color of 11111111 becomes 11111000. I think your math is OK - You multiply by 255 first, then divide...

Share this post


Link to post
Share on other sites