Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading a Bitmap

Status
Not open for further replies.

Borsin

Programmer
Oct 29, 2001
10
0
0
CA
If someone would just be able to verify the correct way to load a bitmap from a file for me...

This is what I have...

CBitmap testBit;
testBit.LoadBitmap ("C:\\bitmap_folder\\bitmap.bmp");

I think that this is right, however it is not working for me.

Thanks for your time.
 
Hi, the easiest way to load a bitmap is via a resource:

Go under the "insert" menu to "resource". Choose "bitmap" in the list and then click the "import" button. Choose to open all kinds of files in the "file open" dialog that appears - this allows you to import files of type .bmp (NB: If your bitmap has more than 256 colors it will not be shown in the bitmap editor).

Give the bitmap resource a unique identifier such as IDB_MYBITMAP in the resource list.

To load the bitmap ready for drawing, etc.:

// Let's load a bitmap
CBitmap* myBitmap = new CBitmap;
myBitmap->LoadBitmap(IDB_MYBITMAP);

I'm assuming you know how to actually draw the bitmap to the window from here on.

Hope this helps....

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top