1 /*
2 * Example program for the JPGalleg library
3 *
4 * Version 2.6, by Angelo Mottola, 2000-2006
5 *
6 * This example shows how to display JPGs stored in a datafile.
7 */
8
9 #include <allegro.h>
10 #include <jpgalleg.h>
11
12 #include "datafile.h"
13
14
15 int
main(void)16 main(void)
17 {
18 DATAFILE *data;
19 BITMAP *bmp;
20
21 allegro_init();
22 install_keyboard();
23
24 jpgalleg_init();
25
26 set_color_depth(32);
27 if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) {
28 set_color_depth(16);
29 if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) {
30 set_color_depth(15);
31 if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) {
32 allegro_message("Unable to init truecolor 640x480 gfx mode: %s", allegro_error);
33 return -1;
34 }
35 }
36 }
37
38 data = load_datafile("datafile.dat");
39 if (!data) {
40 set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
41 allegro_message("Error loading datafile.dat\n");
42 return -1;
43 }
44
45 clear(screen);
46 bmp = (BITMAP *)data[JPGALLEG_LOGO].dat;
47 blit(bmp, screen, 0, 0, 0, 0, bmp->w, bmp->h);
48 readkey();
49
50 unload_datafile(data);
51
52 return 0;
53 }
54 END_OF_MAIN();
55