Allegro Won't load Images

I'm using Code::Blocks 10.05 and Allegro 5. I tried the following source code from one of the tutorials on bitmaps:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "allegro5/allegro.h"
#include "allegro5/allegro_image.h"
#include <allegro5/allegro_native_dialog.h>
 
int main(){
 
   ALLEGRO_DISPLAY *display = NULL;
   ALLEGRO_BITMAP  *image   = NULL;
 
   if(!al_init()) {
      al_show_native_message_box(display, "Error", "Error", "Failed to initialize allegro!", 
                                 NULL, ALLEGRO_MESSAGEBOX_ERROR);
      return 0;
   }
 
   if(!al_init_image_addon()) {
      al_show_native_message_box(display, "Error", "Error", "Failed to initialize al_init_image_addon!", 
                                 NULL, ALLEGRO_MESSAGEBOX_ERROR);
      return 0;
   }
 
   display = al_create_display(800,600);
 
   if(!display) {
      al_show_native_message_box(display, "Error", "Error", "Failed to initialize display!", 
                                 NULL, ALLEGRO_MESSAGEBOX_ERROR);
      return 0;
   }
 
   image = al_load_bitmap("image.png");
 
   if(!image) {
      al_show_native_message_box(display, "Error", "Error", "Failed to load image!", 
                                 NULL, ALLEGRO_MESSAGEBOX_ERROR);
      al_destroy_display(display);
      return 0;
   }
 
   al_draw_bitmap(image,200,200,0);
 
   al_flip_display();
   al_rest(2);
 
   al_destroy_display(display);
   al_destroy_bitmap(image);
 
   return 0;
}


But it displayed the error message for the image. I tried changing the image loaded, then changed it back and saved a PNG filed named "image" to no avail. The previous tutorials' source codes have worked, so I don't know what's wrong. Do I need to put the image file somewhere?

EDIT
Nevermind. I thought that moving the file might help and it worked. Sorry for the extra forum topic.
Last edited on
Topic archived. No new replies allowed.