00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _GIF_LIB_H
00017 #define _GIF_LIB_H
00018
00019 #define GIF_LIB_VERSION " Version 4.0, "
00020
00021 #define GIF_ERROR 0
00022 #define GIF_OK 1
00023
00024 #ifndef TRUE
00025 #define TRUE 1
00026 #define FALSE 0
00027 #endif
00028
00029 #ifndef NULL
00030 #define NULL 0
00031 #endif
00032
00033 #define GIF_STAMP "GIFVER"
00034 #define GIF_STAMP_LEN sizeof(GIF_STAMP) - 1
00035 #define GIF_VERSION_POS 3
00036 #define GIF87_STAMP "GIF87a"
00037 #define GIF89_STAMP "GIF89a"
00038
00039 #define GIF_FILE_BUFFER_SIZE 16384
00040
00041 typedef int GifBooleanType;
00042 typedef unsigned char GifPixelType;
00043 typedef unsigned char * GifRowType;
00044 typedef unsigned char GifByteType;
00045
00046 #define GIF_MESSAGE(Msg) fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg)
00047 #define GIF_EXIT(Msg) { GIF_MESSAGE(Msg); exit(-3); }
00048
00049 #ifdef SYSV
00050 #define VoidPtr char *
00051 #else
00052 #define VoidPtr void *
00053 #endif
00054
00055 typedef struct GifColorType {
00056 GifByteType Red, Green, Blue;
00057 } GifColorType;
00058
00059 typedef struct ColorMapObject
00060 {
00061 int ColorCount;
00062 int BitsPerPixel;
00063 GifColorType *Colors;
00064 }
00065 ColorMapObject;
00066
00067 typedef struct GifImageDesc {
00068 int Left, Top, Width, Height,
00069 Interlace;
00070 ColorMapObject *ColorMap;
00071 } GifImageDesc;
00072
00073 typedef struct GifFileType {
00074 int SWidth, SHeight,
00075 SColorResolution,
00076 SBackGroundColor;
00077 ColorMapObject *SColorMap;
00078 int ImageCount;
00079 GifImageDesc Image;
00080 struct SavedImage *SavedImages;
00081 VoidPtr UserData;
00082 VoidPtr Private;
00083 } GifFileType;
00084
00085 typedef enum {
00086 UNDEFINED_RECORD_TYPE,
00087 SCREEN_DESC_RECORD_TYPE,
00088 IMAGE_DESC_RECORD_TYPE,
00089 EXTENSION_RECORD_TYPE,
00090 TERMINATE_RECORD_TYPE
00091 } GifRecordType;
00092
00093
00094
00095
00096
00097 typedef enum {
00098 GIF_DUMP_SGI_WINDOW = 1000,
00099 GIF_DUMP_X_WINDOW = 1001
00100 } GifScreenDumpType;
00101
00102
00103 typedef int (*InputFunc)(GifFileType*,GifByteType*,int);
00104
00105
00106
00107
00108 typedef int (*OutputFunc)(GifFileType *, const GifByteType *, int);
00109
00110
00111
00112
00113 #define COMMENT_EXT_FUNC_CODE 0xfe
00114 #define GRAPHICS_EXT_FUNC_CODE 0xf9
00115 #define PLAINTEXT_EXT_FUNC_CODE 0x01
00116 #define APPLICATION_EXT_FUNC_CODE 0xff
00117
00118
00119
00120
00121
00122
00123 GifFileType *EGifOpenFileName(const char *GifFileName, int GifTestExistance);
00124 GifFileType *EGifOpenFileHandle(int GifFileHandle);
00125 GifFileType *EgifOpen(void *userPtr, OutputFunc writeFunc);
00126 int EGifSpew(GifFileType *GifFile);
00127 void EGifSetGifVersion(const char *Version);
00128 int EGifPutScreenDesc(GifFileType *GifFile,
00129 int GifWidth, int GifHeight, int GifColorRes, int GifBackGround,
00130 const ColorMapObject *GifColorMap);
00131 int EGifPutImageDesc(GifFileType *GifFile,
00132 int GifLeft, int GifTop, int Width, int GifHeight, int GifInterlace,
00133 const ColorMapObject *GifColorMap);
00134 int EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen);
00135 int EGifPutPixel(GifFileType *GifFile, GifPixelType GifPixel);
00136 int EGifPutComment(GifFileType *GifFile, const char *GifComment);
00137 int EGifPutExtensionFirst(GifFileType *GifFile, int GifExtCode, int GifExtLen,
00138 const VoidPtr GifExtension);
00139 int EGifPutExtensionNext(GifFileType *GifFile, int GifExtCode, int GifExtLen,
00140 const VoidPtr GifExtension);
00141 int EGifPutExtensionLast(GifFileType *GifFile, int GifExtCode, int GifExtLen,
00142 const VoidPtr GifExtension);
00143 int EGifPutExtension(GifFileType *GifFile, int GifExtCode, int GifExtLen,
00144 const VoidPtr GifExtension);
00145 int EGifPutCode(GifFileType *GifFile, int GifCodeSize,
00146 const GifByteType *GifCodeBlock);
00147 int EGifPutCodeNext(GifFileType *GifFile, const GifByteType *GifCodeBlock);
00148 int EGifCloseFile(GifFileType *GifFile);
00149
00150 #define E_GIF_ERR_OPEN_FAILED 1
00151 #define E_GIF_ERR_WRITE_FAILED 2
00152 #define E_GIF_ERR_HAS_SCRN_DSCR 3
00153 #define E_GIF_ERR_HAS_IMAG_DSCR 4
00154 #define E_GIF_ERR_NO_COLOR_MAP 5
00155 #define E_GIF_ERR_DATA_TOO_BIG 6
00156 #define E_GIF_ERR_NOT_ENOUGH_MEM 7
00157 #define E_GIF_ERR_DISK_IS_FULL 8
00158 #define E_GIF_ERR_CLOSE_FAILED 9
00159 #define E_GIF_ERR_NOT_WRITEABLE 10
00160
00161
00162
00163
00164
00165
00166 GifFileType *DGifOpenFileName(const char *GifFileName);
00167 GifFileType *DGifOpenFileHandle(int GifFileHandle);
00168 GifFileType *DGifOpen( void* userPtr, InputFunc readFunc );
00169 int DGifSlurp(GifFileType *GifFile);
00170 int DGifGetScreenDesc(GifFileType *GifFile);
00171 int DGifGetRecordType(GifFileType *GifFile, GifRecordType *GifType);
00172 int DGifGetImageDesc(GifFileType *GifFile);
00173 int DGifGetLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen);
00174 int DGifGetPixel(GifFileType *GifFile, GifPixelType GifPixel);
00175 int DGifGetComment(GifFileType *GifFile, char *GifComment);
00176 int DGifGetExtension(GifFileType *GifFile, int *GifExtCode,
00177 GifByteType **GifExtension);
00178 int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **GifExtension);
00179 int DGifGetCode(GifFileType *GifFile, int *GifCodeSize,
00180 GifByteType **GifCodeBlock);
00181 int DGifGetCodeNext(GifFileType *GifFile, GifByteType **GifCodeBlock);
00182 int DGifGetLZCodes(GifFileType *GifFile, int *GifCode);
00183 int DGifCloseFile(GifFileType *GifFile);
00184
00185 #define D_GIF_ERR_OPEN_FAILED 101
00186 #define D_GIF_ERR_READ_FAILED 102
00187 #define D_GIF_ERR_NOT_GIF_FILE 103
00188 #define D_GIF_ERR_NO_SCRN_DSCR 104
00189 #define D_GIF_ERR_NO_IMAG_DSCR 105
00190 #define D_GIF_ERR_NO_COLOR_MAP 106
00191 #define D_GIF_ERR_WRONG_RECORD 107
00192 #define D_GIF_ERR_DATA_TOO_BIG 108
00193 #define D_GIF_ERR_NOT_ENOUGH_MEM 109
00194 #define D_GIF_ERR_CLOSE_FAILED 110
00195 #define D_GIF_ERR_NOT_READABLE 111
00196 #define D_GIF_ERR_IMAGE_DEFECT 112
00197 #define D_GIF_ERR_EOF_TOO_SOON 113
00198
00199
00200
00201
00202 int QuantizeBuffer(unsigned int Width, unsigned int Height, int *ColorMapSize,
00203 GifByteType *RedInput, GifByteType *GreenInput, GifByteType *BlueInput,
00204 GifByteType *OutputBuffer, GifColorType *OutputColorMap);
00205
00206
00207
00208
00209
00210 extern int GifQuietPrint;
00211
00212 #ifdef HAVE_VARARGS_H
00213 extern void GifQprintf();
00214 #else
00215 extern void GifQprintf(char *Format, ...);
00216 #endif
00217
00218
00219
00220
00221 extern void PrintGifError(void);
00222 extern int GifLastError(void);
00223
00224
00225
00226
00227 extern int DumpScreen2Gif(const char *FileName,
00228 int ReqGraphDriver,
00229 int ReqGraphMode1,
00230 int ReqGraphMode2,
00231 int ReqGraphMode3);
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244 extern ColorMapObject *MakeMapObject(int ColorCount, const GifColorType *ColorMap);
00245 extern void FreeMapObject(ColorMapObject *Object);
00246 extern ColorMapObject *UnionColorMap(
00247 const ColorMapObject *ColorIn1,
00248 const ColorMapObject *ColorIn2,
00249 GifPixelType ColorTransIn2[]);
00250 extern int BitSize(int n);
00251
00252
00253
00254
00255
00256
00257 typedef struct {
00258 int ByteCount;
00259 char *Bytes;
00260 int Function;
00261 } ExtensionBlock;
00262
00263
00264 typedef struct SavedImage {
00265 GifImageDesc ImageDesc;
00266
00267 char *RasterBits;
00268
00269 int Function;
00270
00271 int ExtensionBlockCount;
00272 ExtensionBlock *ExtensionBlocks;
00273 } SavedImage;
00274
00275 extern void ApplyTranslation(SavedImage *Image, GifPixelType Translation[]);
00276
00277 extern void MakeExtension(SavedImage *New, int Function);
00278 extern int AddExtensionBlock(SavedImage *New, int Len, char ExtData[]);
00279 extern void FreeExtension(SavedImage *Image);
00280
00281 extern SavedImage *MakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom);
00282 extern void FreeSavedImages(GifFileType *GifFile);
00283
00284
00285
00286
00287
00288 #define GIF_FONT_WIDTH 8
00289 #define GIF_FONT_HEIGHT 8
00290 extern unsigned char AsciiTable[][GIF_FONT_WIDTH];
00291
00292 extern void DrawText(SavedImage *Image,
00293 const int x, const int y,
00294 const char *legend,
00295 const int color);
00296
00297 extern void DrawBox(SavedImage *Image,
00298 const int x, const int y,
00299 const int w, const int d,
00300 const int color);
00301
00302 void DrawRectangle(SavedImage *Image,
00303 const int x, const int y,
00304 const int w, const int d,
00305 const int color);
00306
00307 extern void DrawBoxedText(SavedImage *Image,
00308 const int x, const int y,
00309 const char *legend,
00310 const int border,
00311 const int bg,
00312 const int fg);
00313
00314 #endif