123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- #ifndef _GIF_LIB_H_
- #define _GIF_LIB_H_ 1
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define GIFLIB_MAJOR 5
- #define GIFLIB_MINOR 1
- #define GIFLIB_RELEASE 4
- #define GIF_ERROR 0
- #define GIF_OK 1
- #include <stddef.h>
- #include <stdbool.h>
- #include <stdio.h>
- #include <stdlib.h>
- #define GIF_STAMP "GIFVER"
- #define GIF_STAMP_LEN sizeof(GIF_STAMP) - 1
- #define GIF_VERSION_POS 3
- #define GIF87_STAMP "GIF87a"
- #define GIF89_STAMP "GIF89a"
- typedef unsigned char GifPixelType;
- typedef unsigned char *GifRowType;
- typedef unsigned char GifByteType;
- typedef unsigned int GifPrefixType;
- typedef int GifWord;
- typedef struct GifColorType {
- GifByteType Red, Green, Blue;
- } GifColorType;
- typedef struct ColorMapObject {
- int ColorCount;
- int BitsPerPixel;
- bool SortFlag;
- GifColorType *Colors;
- } ColorMapObject;
- typedef struct GifImageDesc {
- GifWord Left, Top, Width, Height;
- bool Interlace;
- ColorMapObject *ColorMap;
- } GifImageDesc;
- typedef struct ExtensionBlock {
- int ByteCount;
- GifByteType *Bytes;
- int Function;
- #define CONTINUE_EXT_FUNC_CODE 0x00
- #define COMMENT_EXT_FUNC_CODE 0xfe
- #define GRAPHICS_EXT_FUNC_CODE 0xf9
- #define PLAINTEXT_EXT_FUNC_CODE 0x01
- #define APPLICATION_EXT_FUNC_CODE 0xff
- } ExtensionBlock;
- typedef struct SavedImage {
- GifImageDesc ImageDesc;
- GifByteType *RasterBits;
- int ExtensionBlockCount;
- ExtensionBlock *ExtensionBlocks;
- } SavedImage;
- typedef struct GifFileType {
- GifWord SWidth, SHeight;
- GifWord SColorResolution;
- GifWord SBackGroundColor;
- GifByteType AspectByte;
- ColorMapObject *SColorMap;
- int ImageCount;
- GifImageDesc Image;
- SavedImage *SavedImages;
- int ExtensionBlockCount;
- ExtensionBlock *ExtensionBlocks;
- int Error;
- void *UserData;
- void *Private;
- } GifFileType;
- #define GIF_ASPECT_RATIO(n) ((n)+15.0/64.0)
- typedef enum {
- UNDEFINED_RECORD_TYPE,
- SCREEN_DESC_RECORD_TYPE,
- IMAGE_DESC_RECORD_TYPE,
- EXTENSION_RECORD_TYPE,
- TERMINATE_RECORD_TYPE
- } GifRecordType;
- typedef int (*InputFunc) (GifFileType *, GifByteType *, int);
- typedef int (*OutputFunc) (GifFileType *, const GifByteType *, int);
- typedef struct GraphicsControlBlock {
- int DisposalMode;
- #define DISPOSAL_UNSPECIFIED 0
- #define DISPOSE_DO_NOT 1
- #define DISPOSE_BACKGROUND 2
- #define DISPOSE_PREVIOUS 3
- bool UserInputFlag;
- int DelayTime;
- int TransparentColor;
- #define NO_TRANSPARENT_COLOR -1
- } GraphicsControlBlock;
- GifFileType *EGifOpenFileName(const char *GifFileName,
- const bool GifTestExistence, int *Error);
- GifFileType *EGifOpenFileHandle(const int GifFileHandle, int *Error);
- GifFileType *EGifOpen(void *userPtr, OutputFunc writeFunc, int *Error);
- int EGifSpew(GifFileType * GifFile);
- const char *EGifGetGifVersion(GifFileType *GifFile);
- int EGifCloseFile(GifFileType *GifFile, int *ErrorCode);
- #define E_GIF_SUCCEEDED 0
- #define E_GIF_ERR_OPEN_FAILED 1
- #define E_GIF_ERR_WRITE_FAILED 2
- #define E_GIF_ERR_HAS_SCRN_DSCR 3
- #define E_GIF_ERR_HAS_IMAG_DSCR 4
- #define E_GIF_ERR_NO_COLOR_MAP 5
- #define E_GIF_ERR_DATA_TOO_BIG 6
- #define E_GIF_ERR_NOT_ENOUGH_MEM 7
- #define E_GIF_ERR_DISK_IS_FULL 8
- #define E_GIF_ERR_CLOSE_FAILED 9
- #define E_GIF_ERR_NOT_WRITEABLE 10
- int EGifPutScreenDesc(GifFileType *GifFile,
- const int GifWidth, const int GifHeight,
- const int GifColorRes,
- const int GifBackGround,
- const ColorMapObject *GifColorMap);
- int EGifPutImageDesc(GifFileType *GifFile,
- const int GifLeft, const int GifTop,
- const int GifWidth, const int GifHeight,
- const bool GifInterlace,
- const ColorMapObject *GifColorMap);
- void EGifSetGifVersion(GifFileType *GifFile, const bool gif89);
- int EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine,
- int GifLineLen);
- int EGifPutPixel(GifFileType *GifFile, const GifPixelType GifPixel);
- int EGifPutComment(GifFileType *GifFile, const char *GifComment);
- int EGifPutExtensionLeader(GifFileType *GifFile, const int GifExtCode);
- int EGifPutExtensionBlock(GifFileType *GifFile,
- const int GifExtLen, const void *GifExtension);
- int EGifPutExtensionTrailer(GifFileType *GifFile);
- int EGifPutExtension(GifFileType *GifFile, const int GifExtCode,
- const int GifExtLen,
- const void *GifExtension);
- int EGifPutCode(GifFileType *GifFile, int GifCodeSize,
- const GifByteType *GifCodeBlock);
- int EGifPutCodeNext(GifFileType *GifFile,
- const GifByteType *GifCodeBlock);
- GifFileType *DGifOpenFileName(const char *GifFileName, int *Error);
- GifFileType *DGifOpenFileHandle(int GifFileHandle, int *Error);
- int DGifSlurp(GifFileType * GifFile);
- GifFileType *DGifOpen(void *userPtr, InputFunc readFunc, int *Error);
- int DGifCloseFile(GifFileType * GifFile, int *ErrorCode);
- #define D_GIF_SUCCEEDED 0
- #define D_GIF_ERR_OPEN_FAILED 101
- #define D_GIF_ERR_READ_FAILED 102
- #define D_GIF_ERR_NOT_GIF_FILE 103
- #define D_GIF_ERR_NO_SCRN_DSCR 104
- #define D_GIF_ERR_NO_IMAG_DSCR 105
- #define D_GIF_ERR_NO_COLOR_MAP 106
- #define D_GIF_ERR_WRONG_RECORD 107
- #define D_GIF_ERR_DATA_TOO_BIG 108
- #define D_GIF_ERR_NOT_ENOUGH_MEM 109
- #define D_GIF_ERR_CLOSE_FAILED 110
- #define D_GIF_ERR_NOT_READABLE 111
- #define D_GIF_ERR_IMAGE_DEFECT 112
- #define D_GIF_ERR_EOF_TOO_SOON 113
- int DGifGetScreenDesc(GifFileType *GifFile);
- int DGifGetRecordType(GifFileType *GifFile, GifRecordType *GifType);
- int DGifGetImageDesc(GifFileType *GifFile);
- int DGifGetLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen);
- int DGifGetPixel(GifFileType *GifFile, GifPixelType GifPixel);
- int DGifGetComment(GifFileType *GifFile, char *GifComment);
- int DGifGetExtension(GifFileType *GifFile, int *GifExtCode,
- GifByteType **GifExtension);
- int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **GifExtension);
- int DGifGetCode(GifFileType *GifFile, int *GifCodeSize,
- GifByteType **GifCodeBlock);
- int DGifGetCodeNext(GifFileType *GifFile, GifByteType **GifCodeBlock);
- int DGifGetLZCodes(GifFileType *GifFile, int *GifCode);
- int GifQuantizeBuffer(unsigned int Width, unsigned int Height,
- int *ColorMapSize, GifByteType * RedInput,
- GifByteType * GreenInput, GifByteType * BlueInput,
- GifByteType * OutputBuffer,
- GifColorType * OutputColorMap);
- extern const char *GifErrorString(int ErrorCode);
- extern ColorMapObject *GifMakeMapObject(int ColorCount,
- const GifColorType *ColorMap);
- extern void GifFreeMapObject(ColorMapObject *Object);
- extern ColorMapObject *GifUnionColorMap(const ColorMapObject *ColorIn1,
- const ColorMapObject *ColorIn2,
- GifPixelType ColorTransIn2[]);
- extern int GifBitSize(int n);
- extern void *
- reallocarray(void *optr, size_t nmemb, size_t size);
- extern void GifApplyTranslation(SavedImage *Image, GifPixelType Translation[]);
- extern int GifAddExtensionBlock(int *ExtensionBlock_Count,
- ExtensionBlock **ExtensionBlocks,
- int Function,
- unsigned int Len, unsigned char ExtData[]);
- extern void GifFreeExtensions(int *ExtensionBlock_Count,
- ExtensionBlock **ExtensionBlocks);
- extern SavedImage *GifMakeSavedImage(GifFileType *GifFile,
- const SavedImage *CopyFrom);
- extern void GifFreeSavedImages(GifFileType *GifFile);
- int DGifExtensionToGCB(const size_t GifExtensionLength,
- const GifByteType *GifExtension,
- GraphicsControlBlock *GCB);
- size_t EGifGCBToExtension(const GraphicsControlBlock *GCB,
- GifByteType *GifExtension);
- int DGifSavedExtensionToGCB(GifFileType *GifFile,
- int ImageIndex,
- GraphicsControlBlock *GCB);
- int EGifGCBToSavedExtension(const GraphicsControlBlock *GCB,
- GifFileType *GifFile,
- int ImageIndex);
- #define GIF_FONT_WIDTH 8
- #define GIF_FONT_HEIGHT 8
- extern const unsigned char GifAsciiTable8x8[][GIF_FONT_WIDTH];
- extern void GifDrawText8x8(SavedImage *Image,
- const int x, const int y,
- const char *legend, const int color);
- extern void GifDrawBox(SavedImage *Image,
- const int x, const int y,
- const int w, const int d, const int color);
- extern void GifDrawRectangle(SavedImage *Image,
- const int x, const int y,
- const int w, const int d, const int color);
- extern void GifDrawBoxedText8x8(SavedImage *Image,
- const int x, const int y,
- const char *legend,
- const int border, const int bg, const int fg);
- #ifdef __cplusplus
- }
- #endif
- #endif
|