I can't seem to output a bitmap...

I've been trying to output a simple bitmap image that is the same size as the window that I have the program open in. The file is located in the same folder as the project. You'll notice that I have it give me an error message to let me know when it fails to open it. Here's my code:

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
#include <allegro.h>
int main (void)
{
	char *filename = "gradient.BMP";
	BITMAP *image;
	int ret;
	allegro_init();
	install_keyboard();
	set_color_depth(16);
	ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);

	if (ret != 0){
		allegro_message(allegro_error);
		return 1;
	}
	image = load_bitmap(filename, NULL);
	if (!image){
		allegro_message("Error loading %s", filename);
		return 1;
	}
	blit(image, screen, 0,0,0,0, SCREEN_W, SCREEN_H);
	destroy_bitmap(image);
	textprintf_ex(screen, font, 0, 0, 1, -1, "%dx%d", SCREEN_W, SCREEN_H);
	while(!keypressed());
	allegro_exit();
	return 0;
}
END_OF_MAIN()


Any suggestions?
I suggest that you tell us what the problem is. We don't read minds ;)
Last edited on
Sorry I thought the title explained it. Basically I can't get it to output the image. All I get is the popup message that says there was an error loading it (a message i coded it to say in the event of an there being no image)
Well, the title tells me "something is wrong". It does not say "it crashes" or "it freezes" or"my debug dialog comes up" or "I get the blue screen of death except it looks like the one from Windows 8 and I'm on a *nix".

Have you checked to see if the file you're trying to create already exists? Have you checked to see if your program creates it but doesn't finish writing to it?

I have to wonder why you're using a function with "load" in its name when your thread title suggests you want to use a function with "save" in its name.
Edit: Er, do you mean "output" as in "output to file" or "output to screen"? It's a bit ambiguous to me.
Last edited on
output to screen. The file is already made. It doesn't crash or freeze and I dont get any compiler errors.
Can you get an error code instead of that generic "Error loading <file>"?
Last edited on
I get a few warnings but no errors. It says 1 succeeded, 0 failed. And what do you mean by another error code?
I'm not talking about your compiler output. I'm asking if you can modify your program to see exactly what the error was. Line 13, for instance, could it be incorporated into line 18?
Topic archived. No new replies allowed.