-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpix2gif.h
157 lines (134 loc) · 3.81 KB
/
pix2gif.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/* pix2gif.h
*
* pix2gif.c header file.
*
* Mark Howell 26 August 1992 [email protected]
*
*/
#include <stdio.h>
#include <stdlib.h>
#if !defined(FILENAME_MAX)
#define FILENAME_MAX 255
#endif
#if !defined(EXIT_SUCCESS)
#define EXIT_SUCCESS 0
#endif
#if !defined(EXIT_FAILURE)
#define EXIT_FAILURE 1
#endif
#if !defined(SEEK_SET)
#define SEEK_SET 0
#endif
#ifdef __DJGPP__
#undef __MSDOS__
#endif
#if defined(__MSDOS__)
#define __USE_FARPTRS__
#endif
/*
7/3 -- I'm guessing "unix" was used for non-ANSI C dialects.
So I'm replacing those tests with #ifndef __STDC__
*/
#ifndef __STDC__
#define const
#endif
#define MAX_BIT 512 /* Must be less than or equal to CODE_TABLE_SIZE */
#define CODE_SIZE 8
#define CODE_TABLE_SIZE 4096
#define PREFIX 0
#define PIXEL 1
#define RED 0
#define GREEN 1
#define BLUE 2
#define CURRENT_VERSION "GIF89a"
#define HASH_SIZE 8192
#define hashfunc(a, b) ((long) ((long) (a) + (long) (b)) % HASH_SIZE)
typedef struct header_s {
unsigned char part;
unsigned char flags;
unsigned short unknown1;
unsigned short images;
unsigned short unknown2;
unsigned char dir_size;
unsigned char unknown3;
unsigned short checksum;
unsigned short unknown4;
unsigned short version;
} header_t;
typedef struct pdirectory_s {
short image_number;
short image_width;
short image_height;
short image_flags;
long image_data_addr;
long image_cm_addr;
} pdirectory_t;
typedef struct image_s {
short width;
short height;
short colours;
long pixels;
#ifdef __USE_FARPTRS__
unsigned char huge *image;
#else
unsigned char *image;
#endif
unsigned char (*colourmap)[3];
unsigned short transflag;
unsigned short transpixel;
} image_t;
typedef struct compress_s {
short next_code;
short slen;
short sptr;
short tlen;
short tptr;
} compress_t;
typedef struct nlist_s {
struct nlist_s *next;
short prefix;
short pixel;
short code;
} nlist_t;
#define sig_k_bln 6
struct sigdef {
char sig_t_signature[6]; /* gif signature */
};
#define sd_m_pixel 7
#define sd_m_zero 8
#define sd_m_cr 112
#define sd_m_gcm 128
#define sd_k_bln 7
struct sddef {
unsigned short sd_w_width; /* width of screen */
unsigned short sd_w_height; /* height of screen */
struct { /* flags */
unsigned sd_v_pixel : 3; /* # bits/pixel in image */
unsigned sd_v_zero : 1; /* reserved */
unsigned sd_v_cr : 3; /* # bits of colour resolution */
unsigned sd_v_gcm : 1; /* global colourmap present */
} sd_r_flags;
unsigned char sd_b_background; /* background colour */
unsigned char sd_b_mbz; /* null terminating byte */
};
#define id_m_pixel 7
#define id_m_zero 56
#define id_m_interlace 64
#define id_m_lcm 128
#define id_k_bln 9
struct iddef {
unsigned short id_w_left; /* image left */
unsigned short id_w_top; /* image right */
unsigned short id_w_width; /* image width */
unsigned short id_w_height; /* image height */
struct { /* flags */
unsigned id_v_pixel : 3; /* # bits/pixel in image */
unsigned id_v_zero : 3; /* reserved */
unsigned id_v_interlace : 1; /* interlaced image */
unsigned id_v_lcm : 1; /* local colourmap present */
} id_r_flags;
};
#define ext_k_bln 1
struct extdef {
unsigned char ext_b_fcode; /* function code */
};