int LoadBitmapFile(char *filename, LPDIRECTDRAWSURFACE surface)
{
HDC sourcedc;
HDC destdc;
HBITMAP hbitmap;
BITMAP bmp;
int height,width;
hbitmap = (HBITMAP)LoadImage(NULL,filename,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION | LR_LOADFROMFILE);
sourcedc =CreateCompatibleDC(NULL);
SelectObject(sourcedc,hbitmap);
GetObject(hbitmap,sizeof(BITMAP),&bmp);
width = bmp.bmWidth;
height = bmp.bmHeight;
surface->GetDC(&destdc);
BitBlt(destdc,0,0,width,height,sourcedc,0,0,SRCCOPY);
surface->ReleaseDC(destdc);
DeleteDC(destdc);
return(0);
}
When I run it through the debugger I get
DDraw:ERROR:Could not obtain DC
DDraw:ERROR:No DC allocated
Edited by - yq on June 21, 2001 11:22:19 PM
can't load .bmp
This one is driving me crazy. Here is my bitmap loader.
change this:
surface->GetDC(&destdc);
to this:
surface->GetDC(destdc);
You are passing an HDC, which is a handle to a Device Context, which means the dereferencing (is that the correct word?) has been done for you.
Cheers
surface->GetDC(&destdc);
to this:
surface->GetDC(destdc);
You are passing an HDC, which is a handle to a Device Context, which means the dereferencing (is that the correct word?) has been done for you.
Cheers
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement