------------------
Dance with me......
Bitmap color depth problem
------------------
Dance with me......
hbmp = (HBITMAP)LoadImage(hInst, fname, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
GetObject(hbmp, sizeof(BITMAP), &bm);
ddsd.ddpfPixelFormat.dwRGBBitCount = bm.bmBitsPixel;
Jim Adams
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8;
but if it's not, i just can use:
ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
Now if it's not 1, 4, or 8, I also seem to need to define the ddsd.ddpfPixelFormat.dwRBitMask, dwGBitMask, and dwBBitMask.
Currently the bitmap I write is all black, and i think it's because I don't know how to fill out those three values. So how do i do this?
unsigned char rbits, gbits, bbits;
rbits = dwRBitMask << 16;
gbits = dwGBitMask << 8;
bbits = dwBBitMask ;
Or something along those lines. CJ would probably be the guy to answer it correctly though Hopefully I didn't screw you up too bad.
------------------
Still Learning...
i'm not sure what you're trying to do, and i'm not sure why you're trying to do it...
are you using the bit depth of the bitmap for the bitdepth of a pixel format for use in a call to IDirectDrawSurface::SetSurfaceDesc()? or is this for a call to IDirectDraw::CreateSurface()?
neither one really makes any sense, since eventually you'll have a call that makes the surface incompatible with the primary (and why would someone want to do that?)
if your goal is to load a bitmap from a file and have it wind up on a surface, then you need to:
a) load the bitmap (as you are doing)
b) use GetObject to get the stats of the bitmap(as you are doing)
c) use the width and height to create an offscreenplain surface (DONT use the bpp anywhere)
d) create a system DC with CreateCompatibleDC
e) use SelectObject to select the bitmap you loaded into the system DC you just created (be sure to save the return value from SelectObject, as you will be restoring it late)
f) use the GetDC() member function of the new surface you created
g) BitBlt the contents of the system DC onto the new surface
h) use the ReleaseDC() member function of the new surface
i) use SelectObject to restore the old bitmap to the system dc
j) delete the bitmap you loaded
k) delete the system dc
follow these steps, and you wont have to care about the bpp of the bitmap OR the bpp of the primary surface, or the bpp of anything. the call to BitBlt handles all of the conversion for you.
****LET THE PLATFORM DO THE WORK****
Get off my lawn!