Skip to main content
gamedev.net
🔒 Locked

Including Bitmap files

Started by [HBB]Raven 10 replies 1.6k views
Original Post
[HBB]Raven
[HBB]Raven
How do I include a bitmap file in my .EXE ? I have defined it as a resource(.rc and .h) and I have included it in my resource directory but it is only accessed by my proggy as long as I don't move the .EXE elsewhere. Therefore I am assuming the .BMP code is not contained within the .EXE. This is very odd as I have it working for .ICO I'm using VC++ 6.0 and a Bitmap loading routing and accessing the .BMP file using a string definition (e.g. "name.bmp"). Any ideas ? Edited by - [HBB]Raven on 7/3/00 6:55:41 AM
RAVEN
byondo
byondo
> I''m using VC++ 6.0 and a Bitmap loading routing and accessing
> the .BMP file using a string definition (e.g. "name.bmp").

There''s your problem. You are loading the bitmap by name at runtime, so if the corresponding file can''t be found (relative to the current dir), it won''t work. Instead load it by resource id, something like:

LoadBitmap(MAKEINTRESOURCE(IDB_MYBITMAP));

Hopefully that will do the trick.
DeltaVee
DeltaVee
Try inserting the bitmap into your project (right click on the resource screen or through the menu) then you can load it via the resource ID.

--------------------------
Carpe Diem
D.V.Carpe Die<FONT C
[HBB]Raven
[HBB]Raven
I''ve tried using MAKEINTRESOURCE(ID_BITMAP1) but it tells me that
ID_BITMAP1 isn''t defined

Even so, I have the RES tab and it contains ID_BITMAP1 and the
details for ID_BITMAP1 contain a filename of "image_name.bmp"

Help !









//\_/\\
//\(v)/\\
// X^X \\
/_\


RAVEN
Muzzafarath
Muzzafarath
Have you #includ:ed your resource.h in the file that's using MAKEINTRESOURCE(ID_BITMAP1)?

- Muzzafarath

Mad House Software
The Field Marshals

Edited by - Muzzafarath on July 3, 2000 9:51:55 AM
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
DeltaVee
DeltaVee
did you add the resource to the project?

Go to ''Add files'' and select everything (*.*)

--------------------------
Carpe Diem
D.V.Carpe Die<FONT C
[HBB]Raven
[HBB]Raven
I have only included the resource.h in the resource.rc file.

Does it also need to go into my_prog.cpp ?

Thanks for the speedy replies BTW - much appreciated :D
RAVEN
DeltaVee
DeltaVee
No you need to add the .rc file to your project.

Click on the workspace button on the tool bar, to bring up your workspace, if it is not showing already.

Select the File View Tab.

Right click on the project name (in the tree view). Select 'Add Files to Project...).

Now add you .rc file.

--------------------------
Carpe Diem

Edited by - DeltaVee on July 3, 2000 10:38:31 AM
D.V.Carpe Die<FONT C
Phantasm
Phantasm
resource.h needs to be included in my_prog.cpp (to use the filename you used). If you are using Visual C++, then if you choose to create a new .rc file from Visual C++ w/ my_prog project open (are you following me?), then the .rc and resource.h files will already have been included in the PROJECT (that is, they will be linked into the final .exe, I believe). All you need to do, then, is #include "resource.h"

P h a n t a s m
"I'd feel safer if the helicopter had an ejection seat."
Phantasm
[HBB]Raven
[HBB]Raven
Mucho thanks people - problem solved.




RAVEN

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.