Sign in to follow this  
m4ster

Color Conversation SOLVED

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this