Skip to content

allefant/algif5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

algif5

About

algif5 is a gif loading library for Allegro 5. Homepage, Github.

Download

algif5.zip
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;
};

Documentation

algif_load_animation

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.

algif_get_bitmap

al_draw_bitmap(algif_get_bitmap(gif, al_get_time()), x, y, 0);

Get a bitmap for the current frame.

algif_destroy_animation

algif_destroy_animation(gif);

Destroy the gif again.

algif_get_frame_bitmap

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.

algif_get_frame_duration

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.

Installation

Unfortunately I'm bad with build systems and makefiles and so on, so instead just do this:
  • Place algif.h somewhere where your compiler will find it.
  • When compiling your code, make sure algif.c, bitmap.c, gif.c and lzw.c are compiled along.
I also included a makefile in the .zip to create the example program but it probably only works in Linux. Allegro 5 (including the primitives addon) is required.

Examples

The download comes with an example program.

About

GIF addon for Allegro 5

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published