struct ALGIF_ANIMATION { int width, height; int frames_count; int background_index; /* -1 = no, 0 = forever, * 1..65535 = that many times */ int loop; ALGIF_PALETTE palette; ALGIF_FRAME *frames; int duration; }; struct ALGIF_FRAME { ALGIF_BITMAP *bitmap_8_bit; ALGIF_PALETTE palette; int xoff, yoff; /* in 1/100th seconds */ int duration; /* 0 = don't care, 1 = keep, * 2 = background, 3 = previous */ int disposal_method; int transparent_index; }; struct ALGIF_BITMAP { int w, h; uint8_t *data; }; struct ALGIF_PALETTE { int colors_count; ALGIF_RGB colors[256]; }; struct ALGIF_RGB { uint8_t r, g, b; };
ALGIF_ANIMATION *gif = algif_load_animation(char const *filename); ALGIF_ANIMATION *gif = algif_load_animation_f(ALLEGRO_FILE *file);
Load a gif. Either by specifying the filename or by passing an ALLEGRO_FILE opened for reading.
al_draw_bitmap(algif_get_bitmap(gif, al_get_time()), x, y, 0);
Get a bitmap for the current frame.
algif_destroy_animation(gif);
Destroy the gif again.
ALLEGRO_BITMAP *algif_get_frame_bitmap(ALGIF_ANIMATION *gif, int i);
Get the n-th frame of the gif. The parameter i can be any value from 0 to gif->frames_count - 1.
double algif_get_frame_duration(ALGIF_ANIMATION *gif, int i);
Get the duration of the n-th frame of the gif, in seconds. The parameter i can be any value from 0 to gif->frames_count - 1.
The download comes with an example program.