libnsgif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
libnsgif.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004 Richard Wilson <richard.wilson@netsurf-browser.org>
3  * Copyright 2008 Sean Fox <dyntryx@gmail.com>
4  *
5  * This file is part of NetSurf's libnsgif, http://www.netsurf-browser.org/
6  * Licenced under the MIT License,
7  * http://www.opensource.org/licenses/mit-license.php
8  */
9 
15 #ifndef _LIBNSGIF_H_
16 #define _LIBNSGIF_H_
17 
18 #include <stdbool.h>
19 #include <inttypes.h>
20 
21 /* Error return values */
22 typedef enum {
24  GIF_OK = 0,
32 } gif_result;
33 
35 typedef struct gif_frame {
37  bool display;
39  unsigned int frame_delay;
40 
41  /* Internal members are listed below */
42 
44  unsigned int frame_pointer;
46  bool virgin;
48  bool opaque;
52  unsigned char disposal_method;
56  unsigned char transparency_index;
58  unsigned int redraw_x;
60  unsigned int redraw_y;
62  unsigned int redraw_width;
64  unsigned int redraw_height;
65 } gif_frame;
66 
67 /* API for Bitmap callbacks */
68 typedef void* (*gif_bitmap_cb_create)(int width, int height);
69 typedef void (*gif_bitmap_cb_destroy)(void *bitmap);
70 typedef unsigned char* (*gif_bitmap_cb_get_buffer)(void *bitmap);
71 typedef void (*gif_bitmap_cb_set_opaque)(void *bitmap, bool opaque);
72 typedef bool (*gif_bitmap_cb_test_opaque)(void *bitmap);
73 typedef void (*gif_bitmap_cb_modified)(void *bitmap);
74 
76 typedef struct gif_bitmap_callback_vt {
83 
84  /* Members below are optional */
85 
93 
95 typedef struct gif_animation {
99  unsigned char *gif_data;
101  unsigned int width;
103  unsigned int height;
105  unsigned int frame_count;
107  unsigned int frame_count_partial;
113  void *frame_image;
118 
119  /* Internal members are listed below */
120 
122  unsigned int buffer_position;
124  unsigned int buffer_size;
126  unsigned int frame_holders;
128  unsigned int background_index;
130  unsigned int aspect_ratio;
132  unsigned int colour_table_size;
136  unsigned int *global_colour_table;
138  unsigned int *local_colour_table;
139 } gif_animation;
140 
144 void gif_create(gif_animation *gif, gif_bitmap_callback_vt *bitmap_callbacks);
145 
161 gif_result gif_initialise(gif_animation *gif, size_t size, unsigned char *data);
162 
176 gif_result gif_decode_frame(gif_animation *gif, unsigned int frame);
177 
181 void gif_finalise(gif_animation *gif);
182 
183 #endif
void(* gif_bitmap_cb_modified)(void *bitmap)
Definition: libnsgif.h:73
bool opaque
Definition: libnsgif.h:48
Definition: libnsgif.h:29
void(* gif_bitmap_cb_set_opaque)(void *bitmap, bool opaque)
Definition: libnsgif.h:71
Definition: libnsgif.h:30
unsigned int aspect_ratio
Definition: libnsgif.h:130
unsigned int frame_count
Definition: libnsgif.h:105
gif_bitmap_cb_destroy bitmap_destroy
Definition: libnsgif.h:80
int loop_count
Definition: libnsgif.h:115
gif_bitmap_cb_modified bitmap_modified
Definition: libnsgif.h:91
gif_result current_error
Definition: libnsgif.h:117
struct gif_bitmap_callback_vt gif_bitmap_callback_vt
unsigned char disposal_method
Definition: libnsgif.h:52
Definition: libnsgif.h:35
unsigned char transparency_index
Definition: libnsgif.h:56
unsigned char * gif_data
Definition: libnsgif.h:99
bool global_colours
Definition: libnsgif.h:134
unsigned int redraw_y
Definition: libnsgif.h:60
bool(* gif_bitmap_cb_test_opaque)(void *bitmap)
Definition: libnsgif.h:72
void *(* gif_bitmap_cb_create)(int width, int height)
Definition: libnsgif.h:68
void * frame_image
Definition: libnsgif.h:113
bool transparency
Definition: libnsgif.h:54
Definition: libnsgif.h:26
unsigned int background_index
Definition: libnsgif.h:128
unsigned int width
Definition: libnsgif.h:101
unsigned int * local_colour_table
Definition: libnsgif.h:138
unsigned int colour_table_size
Definition: libnsgif.h:132
struct gif_animation gif_animation
gif_bitmap_cb_get_buffer bitmap_get_buffer
Definition: libnsgif.h:82
void gif_create(gif_animation *gif, gif_bitmap_callback_vt *bitmap_callbacks)
Definition: libnsgif.c:1187
Definition: libnsgif.h:25
Definition: libnsgif.h:27
struct gif_frame gif_frame
bool redraw_required
Definition: libnsgif.h:50
gif_bitmap_callback_vt bitmap_callbacks
Definition: libnsgif.h:97
Definition: libnsgif.h:28
gif_result gif_decode_frame(gif_animation *gif, unsigned int frame)
Definition: libnsgif.c:1402
unsigned char *(* gif_bitmap_cb_get_buffer)(void *bitmap)
Definition: libnsgif.h:70
gif_frame * frames
Definition: libnsgif.h:109
bool virgin
Definition: libnsgif.h:46
int decoded_frame
Definition: libnsgif.h:111
Definition: libnsgif.h:24
unsigned int redraw_width
Definition: libnsgif.h:62
unsigned int frame_count_partial
Definition: libnsgif.h:107
gif_result
Definition: libnsgif.h:22
gif_bitmap_cb_set_opaque bitmap_set_opaque
Definition: libnsgif.h:87
unsigned int height
Definition: libnsgif.h:103
unsigned int buffer_size
Definition: libnsgif.h:124
unsigned int * global_colour_table
Definition: libnsgif.h:136
Definition: libnsgif.h:23
Definition: libnsgif.h:31
gif_result gif_initialise(gif_animation *gif, size_t size, unsigned char *data)
Definition: libnsgif.c:1196
Definition: libnsgif.h:95
unsigned int redraw_height
Definition: libnsgif.h:64
Definition: libnsgif.h:76
gif_bitmap_cb_test_opaque bitmap_test_opaque
Definition: libnsgif.h:89
gif_bitmap_cb_create bitmap_create
Definition: libnsgif.h:78
unsigned int redraw_x
Definition: libnsgif.h:58
unsigned int frame_pointer
Definition: libnsgif.h:44
unsigned int frame_delay
Definition: libnsgif.h:39
bool display
Definition: libnsgif.h:37
void gif_finalise(gif_animation *gif)
Definition: libnsgif.c:1409
unsigned int frame_holders
Definition: libnsgif.h:126
unsigned int buffer_position
Definition: libnsgif.h:122
void(* gif_bitmap_cb_destroy)(void *bitmap)
Definition: libnsgif.h:69