Jump to content
  • Advertisement
Sign in to follow this  
m4ster

Color Conversation SOLVED

This topic is 4422 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, there's a problem with teh convert-part of my DirectDraw LoadPicture() function. I try to load a 24 BPP Bitmap and convert it to 16 BPP. But after the load all the colors are wrong on my screen. Here's the code i use to load the bitmap and convert it: ======================================================== ... #define _RGB16BIT555(r,g,b) ((b & 31) + ((g & 31) << 5) + ((b & 31) << 10)) #define _RGB16BIT565(r,g,b) ((b & 31) + ((g & 63) << 5) + ((b & 31) << 11)) ... // lpbyImage - BYTE pointer to the 24 bpp image data // lpwSurface - WORD pointer to the 16 bpp surface DWORD dwRGBBitCount = ddsd.ddpfPixelFormat.dwRGBBitCount; ... for(int cY=0; cY < nDDSHeight; cY++) { for(int cX=0; cX<nDDSWidth; cX++) { UCHAR blue = (lpbyImage[(cY*nDDSWidth*3 + cX*3) + 0]), green = (lpbyImage[(cY*nDDSWidth*3 + cX*3) + 1]), red = (lpbyImage[(cY*nDDSWidth*3 + cX*3) + 2]); USHORT color; if(dwRGBBitCount==15) // 5.5.5 Format color=_RGB16BIT555(red, green, blue); else // 5.6.5 Format color=_RGB16BIT565(red, green, blue); lpwSurface[cX + (cY*nDDSPitch)] = color; } } ======================================================== [Edited by - m4ster on June 14, 2006 12:51:06 PM]

Share this post


Link to post
Share on other sites
Advertisement
You're using the five LSBs - aren't you supposted to go with the five MSBs, e.g. (b & 248) >> 5 etc?

Share this post


Link to post
Share on other sites
After a long time without finding the error I decided to rewrite the whole funtion. Hence I used this very good tutorial.

[Edited by - m4ster on January 14, 2007 12:50:56 PM]

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!