Jump to content
  • Advertisement
Sign in to follow this  
Nath_01

bmp's that wont load (-_-)

This topic is 3783 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

i am trying to run a very basic tetris clone and i have finally debugged it all and everything is working....well almost. the code runs fine no compile, linking or any other type of error is reported but all that i get when it opens is a blank window. i think maybe i have missed something when i imported the .bmp im using VC++ express 08 and at the moment all i have done to include the .bmp is add it to the Resource Files folder in the solution explorer...... if any one knows what i have done wrong please help me out, im dying to get this program working. thx in advance nath

Share this post


Link to post
Share on other sites
Advertisement
What functions do you use to load the bitmaps from the resource?

Fr standard GDI functions your bitmap can be any size, the D3DXCreateTextureFromResourceA will usually also be able to load any size.

Did you check the return values of the load functions?

Share this post


Link to post
Share on other sites
this is the load function that i am using for the program.

void bitMapObject::load(HDC hdcCompatible, LPCTSTR lpszFileName)
{
if (hdcMemory)
destroy();
hdcMemory = CreateCompatibleDC (hdcCompatible);
hbmNewBitMap = (HBITMAP)LoadImage(NULL, lpszFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hbmOldBitMap = (HBITMAP)SelectObject (hdcMemory, hbmNewBitMap);
BITMAP bmp;
GetObject (hbmNewBitMap, sizeof(BITMAP), (LPVOID) &bmp);
iWidth = bmp.bmWidth;
iHeight = bmp.bmHeight;
}

this isnt my own code though im using it to learn from, so i
could easily have looked over something.

Share this post


Link to post
Share on other sites
Yes, you need to import the bmp file into your resources.

This will result in a resource-id (per default IDB_BITMAP1).

Now you need to call LoadImage like this:

(HBITMAP)LoadImage( InstanceHandle, MAKEINTRESOURCE( IDB_BITMAP1 ), IMAGE_BITMAP, 0, 0, 0 );


Don't forget that you now need to #include "resource.h" so the program knows about the IDB_BITMAP1 define.

Share this post


Link to post
Share on other sites
ok i have now tried that but vc++ isnt recognising the header file
"resource.h"

one other thing is that when you say "import the bmp file into your resources"
do you mean put the bmp into the resource file folder via add->new item
or am i meant to do it another way???

Share this post


Link to post
Share on other sites
Make sure that:
1. There actually exists a file called resource.h.
2. resource.h is in a path that is visible to the compiler.

Quote:
do you mean put the bmp into the resource file folder via add->new item

You need to add it to the actual resource file. It should have a .rc extension. There should already be one, just look for it in the Solution Explorer. Double click on it and you should get a Resource View window. You should see Bitmap in the tree. Right click and go to Add Resource...Bitmap...Import... and add your bitmap image.

Share this post


Link to post
Share on other sites
ok that would be where my problem is i have nothing with a .rc extension

im not sure if i did it correctly but i tried to create a new resource script
by right clicking the project folder and going to add...new item but i cant see any option to create a .rc file

what am i missing?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!