DirectDraw 16-bit troubles...

Started by
4 comments, last by Oscar_GH 23 years, 8 months ago
Hi, I am using a DirectX wrapper called CDX, currently I am using a 16-bit color mode, but when I use it in FullScreen, and load a 24-bit BMP(Since I cant save a 16-bit bmp), my image colors look a bit different, it seems a bit different like it seems on Paint shop pro or Photoshop. Recently I read an article about 24-bit to 16-bit image coonversion, which compute a new values for each BMP pixel, but I mean , how can I load BMP on a Buffer, and if it is really needed to get my correct colors? Here ese how to convert a 24-bit pixel to 16-bit pixel RedValue = RedValue & 248; GreenValue = GreenValue & 252; BlueValue = BlueValue & 248; RedValue = RedValue << 8 GreenValue = GreenValue << 3 BlueValue = BlueValue >> 3 pixelvalue = RedValue | GreenValue | BlueValue; thanks! Oscar Gracián Tampico Tamaulipas México ogracian@hotmail.com
Advertisement
Hey Oscar,

the computations you are using don''t look right at all!

I use 16bit all the time. This is how i do the conversion:

ZeroMemory(&ddPF, sizeof(ddPF));
ddPF.dwSize = sizeof(ddPF);

// get the information from the back surface
ddret = lpSurface->GetPixelFormat(&ddPF);

DWORD dwRBM = ddPF.dwRBitMask;
DWORD dwGBM = ddPF.dwGBitMask;
DWORD dwBBM = ddPF.dwBBitMask;
// calculate shift left amount
for (iRSHL=0; (dwRBM&1)!=1; iRSHL++) dwRBM>>=1;
for (iGSHL=0; (dwGBM&1)!=1; iGSHL++) dwGBM>>=1;
for (iBSHL=0; (dwBBM&1)!=1; iBSHL++) dwBBM>>=1;
// calculate shift right amount
for (iRSHR=8; (dwRBM&1)==1; iRSHR--) dwRBM>>=1;
for (iGSHR=8; (dwGBM&1)==1; iGSHR--) dwGBM>>=1;
for (iBSHR=8; (dwBBM&1)==1; iBSHR--) dwBBM>>=1;


// for every pixel...
BlueValue = BlueValue>>iBSHR;
GreenValue = GreenValue>>iGSHR;
RedValue = RedValue>>iRSHR;
PixelValue = (BlueValue<<iBSHL) | (GreenValue<<iGSHL) | (RedValue<<iRSHL);
the bottom line got cut off!!
    PixelValue = (BlueValue<<iBSHL) | (GreenValue<<iGSHL) | (RedValue<<iRSHL);    

hope that helps...

Edited by - zenic on August 24, 2000 8:59:46 PM
Hi, and thakns for your help, but I have another question which I really apreciate if you could answer me.

Well I have looked at your code but the new Pixel values that I must compute is accesing the Data that I have loaded in My DirectX surface, or I must read the BMP byte by byte and apply the formulas?

Thanks!
Oscar
You should apply the forumals on the image while you read the bitmap from the file, then you move it to the surface.
Goblineye EntertainmentThe road to success is always under construction
Ok, I will do that, thanks for your help.

Regards!!
Oscar

This topic is closed to new replies.

Advertisement