[GD-Windows] In memory bitmap to HBITMAP
Brought to you by:
vexxed72
From: Brian H. <bri...@py...> - 2001-12-07 02:03:15
|
I'm struggling with something fairly basic -- I want to load a BMP out of a compressed file, convert to an HBITMAP, then blit it into a DDraw surface. I know how to do the first and last part, but the middle is causing problems. Even worse, I'm not getting any errors. Loading the bitmap doesn't seem to be a problem. I load it up and parse and find the BITMAPFILEHEADER and BITMAPINFOHEADER no probs. I also locate the raw bits no problem (and inspect with the debugger to make sure I'm getting what I think I'm getting -- in this case, solid magenta). Looks fine. The next step is to create a DC compatible with the desktop: HDC hDC = CreateCompatibleDC( NULL ); I then create a HBITMAP compatible with DC, and using the bits I pulled: HBITMAP hbm; hbm = CreateDIBitmap( hDC, lpBMIH, CBM_INIT, lpBits, lpBMIH, DIB_RGB_COLORS ); lpBMIH are simply pointers to the appropriate BITMAPINFOHEADER. They have correct values in them. The bitmap is returned successfully. To verify things, I grab the bits out of the Bitmap to make sure everything is cool: GetDIBits( hDC, hbm, 0, iHeight, tempbuffer, &bmi, DIB_RGB_COLORS ); It returns the correct number of scan lines, but tempbuffer is filled with black. This means either the CreateDIBitmap() filled in the bitmap with black, or the GetDIBits() failed somehow. I can't figure out which is the real culprit, but the bitmap is pretty much a black square. Any suggestions on how to hunt this down? |