OSDN Git Service

rebuild: for X86LINUX64/X86LINUX64ICC
[eos/base.git] / hostdepend / X86LINUX64ICC / include / gif_lib.h
1 /******************************************************************************
2 * In order to make life a little bit easier when using the GIF file format,   *
3 * this library was written, and which does all the dirty work...              *
4 *                                                                             *
5 *                                       Written by Gershon Elber,  Jun. 1989  *
6 *                                       Hacks by Eric S. Raymond,  Sep. 1992  *
7 *******************************************************************************
8 * History:                                                                    *
9 * 14 Jun 89 - Version 1.0 by Gershon Elber.                                   *
10 *  3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). *
11 * 15 Sep 90 - Version 2.0 by Eric S. Raymond (Changes to suoport GIF slurp)   *
12 ******************************************************************************/
13
14 #ifndef GIF_LIB_H
15 #define GIF_LIB_H
16
17 #define GIF_LIB_VERSION " Version 2.0, "
18
19 #define GIF_ERROR       0
20 #define GIF_OK          1
21
22 #ifndef TRUE
23 #define TRUE            1
24 #define FALSE           0
25 #endif
26
27 #ifndef NULL
28 #define NULL            0
29 #endif /* NULL */
30
31 #define GIF_FILE_BUFFER_SIZE 16384  /* Files uses bigger buffers than usual. */
32
33 typedef int             GifBooleanType;
34 typedef unsigned char   GifPixelType;
35 typedef unsigned char * GifRowType;
36 typedef unsigned char   GifByteType;
37
38 #define GIF_MESSAGE(Msg) fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg)
39 #define GIF_EXIT(Msg)   { GIF_MESSAGE(Msg); exit(-3); }
40
41 #ifdef SYSV
42 #define VoidPtr char *
43 #else
44 #define VoidPtr void *
45 #endif /* SYSV */
46
47 typedef struct GifColorType {
48     GifByteType Red, Green, Blue;
49 } GifColorType;
50
51 typedef struct ColorMapObject
52 {
53     int ColorCount;
54     int BitsPerPixel;
55     GifColorType *Colors;               /* on malloc(3) heap */
56 }
57 ColorMapObject;
58
59 typedef struct GifImageDesc {
60     int Left, Top, Width, Height,       /* Current image dimensions. */
61         Interlace;                      /* Sequential/Interlaced lines. */
62     ColorMapObject *ColorMap;           /* The local color map */
63 } GifImageDesc;
64
65 typedef struct GifFileType {
66     int SWidth, SHeight,                /* Screen dimensions. */
67         SColorResolution,               /* How many colors can we generate? */
68         SBackGroundColor;               /* I hope you understand this one... */
69     ColorMapObject *SColorMap;          /* NULL if not exists. */
70     int ImageCount;                     /* Number of current image */
71     GifImageDesc Image;                 /* Block describing current image */
72     struct SavedImage *SavedImages;     /* Use this to accumulate file state */
73     VoidPtr Private;                    /* Don't mess with this! */
74 } GifFileType;
75
76 typedef enum {
77     UNDEFINED_RECORD_TYPE,
78     SCREEN_DESC_RECORD_TYPE,
79     IMAGE_DESC_RECORD_TYPE,             /* Begin with ',' */
80     EXTENSION_RECORD_TYPE,              /* Begin with '!' */
81     TERMINATE_RECORD_TYPE               /* Begin with ';' */
82 } GifRecordType;
83
84 /* DumpScreen2Gif routine constants identify type of window/screen to dump.  */
85 /* Note all values below 1000 are reserved for the IBMPC different display   */
86 /* devices (it has many!) and are compatible with the numbering TC2.0        */
87 /* (Turbo C 2.0 compiler for IBM PC) gives to these devices.                 */
88 typedef enum {
89     GIF_DUMP_SGI_WINDOW = 1000,
90     GIF_DUMP_X_WINDOW = 1001
91 } GifScreenDumpType;
92
93 /******************************************************************************
94 * O.K., here are the routines one can access in order to encode GIF file:     *
95 * (GIF_LIB file EGIF_LIB.C).                                                  *
96 ******************************************************************************/
97
98 GifFileType *EGifOpenFileName(char *GifFileName, int GifTestExistance);
99 GifFileType *EGifOpenFileHandle(int GifFileHandle);
100 int EGifSpew(GifFileType *GifFile);
101 void EGifSetGifVersion(char *Version);
102 int EGifPutScreenDesc(GifFileType *GifFile,
103         int GifWidth, int GifHeight, int GifColorRes, int GifBackGround,
104         ColorMapObject *GifColorMap);
105 int EGifPutImageDesc(GifFileType *GifFile,
106         int GifLeft, int GifTop, int Width, int GifHeight, int GifInterlace,
107         ColorMapObject *GifColorMap);
108 int EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen);
109 int EGifPutPixel(GifFileType *GifFile, GifPixelType GifPixel);
110 int EGifPutComment(GifFileType *GifFile, char *GifComment);
111 int EGifPutExtension(GifFileType *GifFile, int GifExtCode, int GifExtLen,
112                                                         VoidPtr GifExtension);
113 int EGifPutCode(GifFileType *GifFile, int GifCodeSize,
114                                                    GifByteType *GifCodeBlock);
115 int EGifPutCodeNext(GifFileType *GifFile, GifByteType *GifCodeBlock);
116 int EGifCloseFile(GifFileType *GifFile);
117
118 #define E_GIF_ERR_OPEN_FAILED   1               /* And EGif possible errors. */
119 #define E_GIF_ERR_WRITE_FAILED  2
120 #define E_GIF_ERR_HAS_SCRN_DSCR 3
121 #define E_GIF_ERR_HAS_IMAG_DSCR 4
122 #define E_GIF_ERR_NO_COLOR_MAP  5
123 #define E_GIF_ERR_DATA_TOO_BIG  6
124 #define E_GIF_ERR_NOT_ENOUGH_MEM 7
125 #define E_GIF_ERR_DISK_IS_FULL  8
126 #define E_GIF_ERR_CLOSE_FAILED  9
127 #define E_GIF_ERR_NOT_WRITEABLE 10
128
129 /******************************************************************************
130 * O.K., here are the routines one can access in order to decode GIF file:     *
131 * (GIF_LIB file DGIF_LIB.C).                                                  *
132 ******************************************************************************/
133
134 GifFileType *DGifOpenFileName(const char *GifFileName);
135 GifFileType *DGifOpenFileHandle(int GifFileHandle);
136 int DGifSlurp(GifFileType *GifFile);
137 int DGifGetScreenDesc(GifFileType *GifFile);
138 int DGifGetRecordType(GifFileType *GifFile, GifRecordType *GifType);
139 int DGifGetImageDesc(GifFileType *GifFile);
140 int DGifGetLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen);
141 int DGifGetPixel(GifFileType *GifFile, GifPixelType GifPixel);
142 int DGifGetComment(GifFileType *GifFile, char *GifComment);
143 int DGifGetExtension(GifFileType *GifFile, int *GifExtCode,
144                                                 GifByteType **GifExtension);
145 int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **GifExtension);
146 int DGifGetCode(GifFileType *GifFile, int *GifCodeSize,
147                                                 GifByteType **GifCodeBlock);
148 int DGifGetCodeNext(GifFileType *GifFile, GifByteType **GifCodeBlock);
149 int DGifGetLZCodes(GifFileType *GifFile, int *GifCode);
150 int DGifCloseFile(GifFileType *GifFile);
151
152 #define D_GIF_ERR_OPEN_FAILED   101             /* And DGif possible errors. */
153 #define D_GIF_ERR_READ_FAILED   102
154 #define D_GIF_ERR_NOT_GIF_FILE  103
155 #define D_GIF_ERR_NO_SCRN_DSCR  104
156 #define D_GIF_ERR_NO_IMAG_DSCR  105
157 #define D_GIF_ERR_NO_COLOR_MAP  106
158 #define D_GIF_ERR_WRONG_RECORD  107
159 #define D_GIF_ERR_DATA_TOO_BIG  108
160 #define D_GIF_ERR_NOT_ENOUGH_MEM 109
161 #define D_GIF_ERR_CLOSE_FAILED  110
162 #define D_GIF_ERR_NOT_READABLE  111
163 #define D_GIF_ERR_IMAGE_DEFECT  112
164 #define D_GIF_ERR_EOF_TOO_SOON  113
165
166 /******************************************************************************
167 * O.K., here are the routines from GIF_LIB file QUANTIZE.C.                   *
168 ******************************************************************************/
169 int QuantizeBuffer(unsigned int Width, unsigned int Height, int *ColorMapSize,
170         GifByteType *RedInput, GifByteType *GreenInput, GifByteType *BlueInput,
171         GifByteType *OutputBuffer, GifColorType *OutputColorMap);
172
173
174 /******************************************************************************
175 * O.K., here are the routines from GIF_LIB file QPRINTF.C.                    *
176 ******************************************************************************/
177 extern int GifQuietPrint;
178
179 #ifdef USE_VARARGS
180 extern void GifQprintf();
181 #else
182 extern void GifQprintf(char *Format, ...);
183 #endif /* USE_VARARGS */
184
185 /******************************************************************************
186 * O.K., here are the routines from GIF_LIB file GIF_ERR.C.                    *
187 ******************************************************************************/
188 extern void PrintGifError(void);
189 extern int GifLastError(void);
190
191 /******************************************************************************
192 * O.K., here are the routines from GIF_LIB file DEV2GIF.C.                    *
193 ******************************************************************************/
194 extern int DumpScreen2Gif(char *FileName,
195                           int ReqGraphDriver,
196                           int ReqGraphMode1,
197                           int ReqGraphMode2,
198                           int ReqGraphMode3);
199
200 /*****************************************************************************
201  *
202  * Everything below this point is new after version 1.2, supporting `slurp
203  * mode' for doing I/O in two big belts with all the image-bashing in core.
204  *
205  *****************************************************************************/
206
207 /******************************************************************************
208 * Color Map handling from ALLOCGIF.C                                          *
209 ******************************************************************************/
210
211 extern ColorMapObject *MakeMapObject(int ColorCount, GifColorType *ColorMap);
212 extern void FreeMapObject(ColorMapObject *Object);
213 extern ColorMapObject *UnionColorMap(ColorMapObject *ColorIn1,
214                               ColorMapObject *ColorIn2,
215                               GifPixelType ColorTransIn2[]);
216 extern int BitSize(int n);
217
218 /******************************************************************************
219 * Support for the in-core structures allocation (slurp mode).                 *
220 ******************************************************************************/
221
222 /* This is the in-core version of an extension record */
223 typedef struct {
224     int         ByteCount;
225     char        *Bytes;         /* on malloc(3) heap */
226 } ExtensionBlock;
227
228 /* This holds an image header, its unpacked raster bits, and extensions */
229 typedef struct SavedImage {
230     GifImageDesc        ImageDesc;
231
232     char                *RasterBits;            /* on malloc(3) heap */
233
234     int                 Function;
235     int                 ExtensionBlockCount;
236     ExtensionBlock      *ExtensionBlocks;       /* on malloc(3) heap */
237 } SavedImage;
238
239 extern void ApplyTranslation(SavedImage *Image, GifPixelType Translation[]);
240
241 extern void MakeExtension(SavedImage *New, int Function);
242 extern int AddExtensionBlock(SavedImage *New, int Len, char ExtData[]);
243 extern void FreeExtension(SavedImage *Image);
244
245 extern SavedImage *MakeSavedImage(GifFileType *GifFile, SavedImage *CopyFrom);
246 extern void FreeSavedImages(GifFileType *GifFile);
247
248 /******************************************************************************
249 * The library's internal utility font                                         *
250 ******************************************************************************/
251
252 #define GIF_FONT_WIDTH  8
253 #define GIF_FONT_HEIGHT 8
254 extern unsigned char AsciiTable[][GIF_FONT_WIDTH];
255
256 extern void DrawText(SavedImage *Image,
257                      const int x, const int y,
258                      const char *legend,
259                      const int color);
260
261 extern void DrawBox(SavedImage *Image,
262                      const int x, const int y,
263                      const int w, const int d,
264                      const int color);
265
266 void DrawRectangle(SavedImage *Image,
267                      const int x, const int y,
268                      const int w, const int d,
269                      const int color);
270
271 extern void DrawBoxedText(SavedImage *Image,
272                      const int x, const int y,
273                      const char *legend,
274                      const int border,
275                      const int bg,
276                      const int fg);
277
278 #endif /* GIF_LIB_H */