load_bitmap problems?

Hi. I've made a program that is supposed to load a bitmap with a sprite onto the screen, but whenever I use the function BITMAP *Simple = load_bitmap("Simple.bmp", NULL);, then I get an error saying:

Allegro.exe has stopped working...
Windows is looking for a solution to the problem....

And then it closes the window!!!
What should I do?

Here's the code:

#include<allegro.h>

int main()
{
allegro_init();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);

BITMAP *Simple = load_bitmap("Simple.bmp", NULL);

draw_sprite(screen, Simple, 400, 300);

readkey();
destroy_bitmap(Simple);
allegro_exit();
}

END_OF_MAIN()


Please help me!
Are you sure load_bitmap is the line with problems ? I think not, the function fail and return a NULL pointer, which you then apply to draw_sprite(...) and so on. Check Simple pointer for NULL and abort if it is so.
"The function fail return a NULL pointer?" What kind of grammar is that? I'm sorry, but I don't understand incorrect grammar in English. Anyway, it might be the computer; I have a Windows 7 HP, and this is the first time I've used Allegro on a computer like this. Anyway, is there a library I can include or something to enable loading bitmaps and sprites? That would REALLY help. Please reply,

-Speaguy
Many times it isn't your Computer the problem. I never had problem using my Win7HPx64 with 1 year of programming.
What modoran means, is that maybe load_bitmap fails (Maybe cannot find the file) and returns 0, Just like BITMAP * Simple = 0;...
Try to include the full filename (Include the path to Simple.bmp) and make sure your Forward Slashes are doubled, like this:
"C:\\Development\\ValidPath"
But not the Back Slashes, like this:
"C:/Development/ValidPath
What method should be the most correct is the second one, as it works on UNIX/Linux, but Windows accepts both.
Last edited on
I tried that already, and it didn't work. I still don't know what to do. Do you have any other suggestions?
After BITMAP * Simple = load_bitmap...
have this line:
if(!Simple) MessageBox(0,"Cannot Load Bitmap","Error",MB_ICONERROR);
And tell us if you get a message box error.
Now my programs won't even open....
I tried uninstalling Dev-C++ and then I re-installed it....
Now I'm just lost. Please help.
Dev-C++? You could have told us before. The forum thinks Dev-C++ is outdated. You may want to take something like Code::Blocks, here: http://www.codeblocks.org/downloads/26
You need to get it with MingW if you don't have it already.
Take some coffee, 70mb's may be many for some people.
Topic archived. No new replies allowed.