Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

yq

can't load .bmp

This topic is 6212 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This one is driving me crazy. Here is my bitmap loader.
  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

Share this post


Link to post
Share on other sites
Advertisement
Yes. I''ve tried it with multiple surfaces and I get the same error.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!