View Full Version : How to load BMP from .EXE as Windows Resource

01-26-2003, 01:05 PM
I've looked at everything in Google and the (outdated) MSDN for an example of loading a BMP from a Windows resource in support of my OpenGL screensaver, but no joy.

I'm getting error code 1814 back from GetLastError() after a CBitmap::LoadBitmap fails which is basically saying: "can't find yer fargin resource in yer fargin EXE u knob".

There is no obvious reason why it won't load; the 256x256 BMP is happily imported in the resource file as IDB_BITMAP1 (ID 110 as it happens) but I'm ready to pull out what little hair I have left.

Does anyone have a cogent source example that works?

Many thanks in advance... Go Raiders!

01-26-2003, 02:02 PM
Nehe at nehe.gamedev.net has a tutorial showing how to do this. I think it is tutorial 38.

Good luck,

01-26-2003, 04:06 PM
There's something wrong with the NeHe tutorial that I have fixed in my own code. They get the actual bits for the bitmap from the bmBits variable in the BITMAP structure they receive from GetObject(). However, the bmBits pointer is always null. You have to use the GetDIBits() function.

[This message has been edited by Tokage (edited 01-26-2003).]

Stack Overflow
01-26-2003, 05:05 PM

Here's an example of how to load a Bitmap from resource and display it in a Screensaver: Screensaver Skeleton 3.1 (http://www.1cplusplusstreet.com/vb/scripts/ShowZip.asp?lngWId=3&lngCodeId=5074&strZipAccessCode=cree50740103)

Hope this helps.


01-27-2003, 06:52 AM

1.0E06 thanks to all for your help... Have a bandit day!

Boo Raiders!