-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgif.h
92 lines (67 loc) · 1.78 KB
/
gif.h
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef INCLUDED_GIF
#define INCLUDED_GIF
#include "typedefs.h"
#include "lzw_encoder.h"
typedef enum {
DISPOSE_UNSPECIFIED,
DISPOSE_NOT,
DISPOSE_BG,
DISPOSE_PREV
} GIFDisposalMethod;
#define LOOP_FOREVER 0xFFFF
typedef struct {
Byte r, g, b;
} GIFColor;
typedef Byte2 GIFUnsigned;
typedef Byte GIFBitField;
typedef Byte GIFColorIndex;
typedef struct GIFFrame {
struct GIFFrame* next;
/* “Graphic Control Extension”. */
Byte reserved2 :3,
disposal :3,
user_input :1,
transparence :1;
Byte2 delay;
Byte transparent_color;
/* “Image Descriptor”. */
Byte2 x, y;
Byte2 w, h;
Byte local_palette :1,
interlace :1,
sort :1,
reserved :2,
palette_size :3;
/* “Local Color Table“. */
GIFColor* palette;
/* Raw (unencoded) data. */
Byte pixels[];
} GIFFrame;
typedef struct GIF {
/* “Logical Screen Descriptor”. */
Byte2 w, h;
Byte global_palette :1,
color_res :3,
sort :1,
palette_size :3;
Byte bg_color;
Byte2 px_ratio;
/* “Global Color Table“. */
GIFColor* palette;
/* Loop count (Netscape “Application Extension Block”). */
Byte2 loop_count;
/* Frames. */
GIFFrame *first, *last;
} GIF;
GIF* GIF_create(Byte2 w, Byte2 h);
GIFColor* GIF_set_palette(GIF* gif, Byte palette_size);
void GIFFrame_set_bg(GIF* gif, GIFColorIndex color);
void GIF_add_frame(GIF* gif, GIFFrame* frame);
void GIF_delete(GIF* gif);
GIFFrame* GIFFrame_create(Byte2 x, Byte2 y, Byte2 w, Byte2 h);
GIFColor* GIFFrame_set_palette(GIFFrame* frame, Byte palette_size);
void GIFFrame_set_transparence(GIFFrame* frame, GIFColorIndex color);
void GIFFrame_delete(GIFFrame* frame);
GIFColor GIFCOLOR(unsigned code);
bool GIF_write(const GIF* gif, const char* filename);
#endif