0N/A/*
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/******************************************************************************
0N/A * In order to make life a little bit easier when using the GIF file format,
0N/A * this library was written, and which does all the dirty work...
0N/A *
0N/A * Written by Gershon Elber, Jun. 1989
0N/A * Hacks by Eric S. Raymond, Sep. 1992
0N/A ******************************************************************************
0N/A * History:
0N/A * 14 Jun 89 - Version 1.0 by Gershon Elber.
0N/A * 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names)
0N/A * 15 Sep 90 - Version 2.0 by Eric S. Raymond (Changes to suoport GIF slurp)
0N/A * 26 Jun 96 - Version 3.0 by Eric S. Raymond (Full GIF89 support)
0N/A * 17 Dec 98 - Version 4.0 by Toshio Kuratomi (Fix extension writing code)
0N/A *****************************************************************************/
0N/A
0N/A/* all encoding functionality stripped */
0N/A
0N/A#ifndef _GIF_LIB_H_
0N/A#define _GIF_LIB_H_ 1
0N/A
0N/A#ifdef __cplusplus
0N/Aextern "C" {
0N/A#endif /* __cplusplus */
0N/A
0N/A#define GIF_LIB_VERSION " Version 4.1, "
0N/A
0N/A#define GIF_ERROR 0
0N/A#define GIF_OK 1
0N/A
0N/A#ifndef TRUE
0N/A#define TRUE 1
0N/A#endif /* TRUE */
0N/A#ifndef FALSE
0N/A#define FALSE 0
0N/A#endif /* FALSE */
0N/A
0N/A#ifndef NULL
0N/A#define NULL 0
0N/A#endif /* NULL */
0N/A
0N/A#define GIF_STAMP "GIFVER" /* First chars in file - GIF stamp. */
0N/A#define GIF_STAMP_LEN sizeof(GIF_STAMP) - 1
0N/A#define GIF_VERSION_POS 3 /* Version first character in stamp. */
0N/A#define GIF87_STAMP "GIF87a" /* First chars in file - GIF stamp. */
0N/A#define GIF89_STAMP "GIF89a" /* First chars in file - GIF stamp. */
0N/A
0N/A#define GIF_FILE_BUFFER_SIZE 16384 /* Files uses bigger buffers than usual. */
0N/A
0N/Atypedef int GifBooleanType;
0N/Atypedef unsigned char GifPixelType;
0N/Atypedef unsigned char *GifRowType;
0N/Atypedef unsigned char GifByteType;
0N/A
0N/A#define GIF_MESSAGE(Msg) fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg)
0N/A#define GIF_EXIT(Msg) { GIF_MESSAGE(Msg); exit(-3); }
0N/A
0N/A#ifdef SYSV
0N/A#define VoidPtr char *
0N/A#else
0N/A#define VoidPtr void *
0N/A#endif /* SYSV */
0N/A
0N/Atypedef struct GifColorType {
0N/A GifByteType Red, Green, Blue;
0N/A} GifColorType;
0N/A
0N/Atypedef struct ColorMapObject {
0N/A int ColorCount;
0N/A int BitsPerPixel;
0N/A GifColorType *Colors; /* on malloc(3) heap */
0N/A} ColorMapObject;
0N/A
0N/Atypedef struct GifImageDesc {
0N/A int Left, Top, Width, Height, /* Current image dimensions. */
0N/A Interlace; /* Sequential/Interlaced lines. */
0N/A ColorMapObject *ColorMap; /* The local color map */
0N/A} GifImageDesc;
0N/A
0N/Atypedef struct GifFileType {
0N/A int SWidth, SHeight, /* Screen dimensions. */
0N/A SColorResolution, /* How many colors can we generate? */
0N/A SBackGroundColor; /* I hope you understand this one... */
0N/A ColorMapObject *SColorMap; /* NULL if not exists. */
0N/A int ImageCount; /* Number of current image */
0N/A GifImageDesc Image; /* Block describing current image */
0N/A struct SavedImage *SavedImages; /* Use this to accumulate file state */
0N/A VoidPtr UserData; /* hook to attach user data (TVT) */
0N/A VoidPtr Private; /* Don't mess with this! */
0N/A} GifFileType;
0N/A
0N/Atypedef enum {
0N/A UNDEFINED_RECORD_TYPE,
0N/A SCREEN_DESC_RECORD_TYPE,
0N/A IMAGE_DESC_RECORD_TYPE, /* Begin with ',' */
0N/A EXTENSION_RECORD_TYPE, /* Begin with '!' */
0N/A TERMINATE_RECORD_TYPE /* Begin with ';' */
0N/A} GifRecordType;
0N/A
0N/A/* DumpScreen2Gif routine constants identify type of window/screen to dump.
0N/A * Note all values below 1000 are reserved for the IBMPC different display
0N/A * devices (it has many!) and are compatible with the numbering TC2.0
0N/A * (Turbo C 2.0 compiler for IBM PC) gives to these devices.
0N/A */
0N/Atypedef enum {
0N/A GIF_DUMP_SGI_WINDOW = 1000,
0N/A GIF_DUMP_X_WINDOW = 1001
0N/A} GifScreenDumpType;
0N/A
0N/A/* func type to read gif data from arbitrary sources (TVT) */
0N/Atypedef int (*InputFunc) (GifFileType *, GifByteType *, int);
0N/A
0N/A/* func type to write gif data ro arbitrary targets.
0N/A * Returns count of bytes written. (MRB)
0N/A */
0N/Atypedef int (*OutputFunc) (GifFileType *, const GifByteType *, int);
0N/A
0N/A/******************************************************************************
0N/A * GIF89 extension function codes
0N/A******************************************************************************/
0N/A
0N/A#define COMMENT_EXT_FUNC_CODE 0xfe /* comment */
0N/A#define GRAPHICS_EXT_FUNC_CODE 0xf9 /* graphics control */
0N/A#define PLAINTEXT_EXT_FUNC_CODE 0x01 /* plaintext */
0N/A#define APPLICATION_EXT_FUNC_CODE 0xff /* application block */
0N/A
0N/A/******************************************************************************
0N/A * O.K., here are the routines one can access in order to decode GIF file:
0N/A * (GIF_LIB file DGIF_LIB.C).
0N/A *****************************************************************************/
0N/A
0N/AGifFileType *DGifOpenFileName(const char *GifFileName);
0N/AGifFileType *DGifOpenFileHandle(int GifFileHandle);
0N/AGifFileType *DGifOpen(void *userPtr, InputFunc readFunc); /* new one
0N/A * (TVT) */
0N/Aint DGifSlurp(GifFileType * GifFile);
0N/Aint DGifGetScreenDesc(GifFileType * GifFile);
0N/Aint DGifGetRecordType(GifFileType * GifFile, GifRecordType * GifType);
0N/Aint DGifGetImageDesc(GifFileType * GifFile);
0N/Aint DGifGetLine(GifFileType * GifFile, GifPixelType * GifLine, int GifLineLen);
0N/Aint DGifGetPixel(GifFileType * GifFile, GifPixelType GifPixel);
0N/Aint DGifGetComment(GifFileType * GifFile, char *GifComment);
0N/Aint DGifGetExtension(GifFileType * GifFile, int *GifExtCode,
0N/A GifByteType ** GifExtension);
0N/Aint DGifGetExtensionNext(GifFileType * GifFile, GifByteType ** GifExtension);
0N/Aint DGifGetCode(GifFileType * GifFile, int *GifCodeSize,
0N/A GifByteType ** GifCodeBlock);
0N/Aint DGifGetCodeNext(GifFileType * GifFile, GifByteType ** GifCodeBlock);
0N/Aint DGifGetLZCodes(GifFileType * GifFile, int *GifCode);
0N/Aint DGifCloseFile(GifFileType * GifFile);
0N/A
0N/A#define D_GIF_ERR_OPEN_FAILED 101 /* And DGif possible errors. */
0N/A#define D_GIF_ERR_READ_FAILED 102
0N/A#define D_GIF_ERR_NOT_GIF_FILE 103
0N/A#define D_GIF_ERR_NO_SCRN_DSCR 104
0N/A#define D_GIF_ERR_NO_IMAG_DSCR 105
0N/A#define D_GIF_ERR_NO_COLOR_MAP 106
0N/A#define D_GIF_ERR_WRONG_RECORD 107
0N/A#define D_GIF_ERR_DATA_TOO_BIG 108
0N/A#define D_GIF_ERR_NOT_ENOUGH_MEM 109
0N/A#define D_GIF_ERR_CLOSE_FAILED 110
0N/A#define D_GIF_ERR_NOT_READABLE 111
0N/A#define D_GIF_ERR_IMAGE_DEFECT 112
0N/A#define D_GIF_ERR_EOF_TOO_SOON 113
0N/A
0N/A
0N/A/******************************************************************************
0N/A * O.K., here are the routines from GIF_LIB file GIF_ERR.C.
0N/A******************************************************************************/
0N/Aextern void PrintGifError(void);
0N/Aextern int GifLastError(void);
0N/A
0N/A/******************************************************************************
0N/A * O.K., here are the routines from GIF_LIB file DEV2GIF.C.
0N/A******************************************************************************/
0N/Aextern int DumpScreen2Gif(const char *FileName,
0N/A int ReqGraphDriver,
0N/A long ReqGraphMode1,
0N/A long ReqGraphMode2,
0N/A long ReqGraphMode3);
0N/A
0N/A/*****************************************************************************
0N/A *
0N/A * Everything below this point is new after version 1.2, supporting `slurp
0N/A * mode' for doing I/O in two big belts with all the image-bashing in core.
0N/A *
0N/A *****************************************************************************/
0N/A
0N/A/******************************************************************************
0N/A * Color Map handling from ALLOCGIF.C
0N/A *****************************************************************************/
0N/A
0N/Aextern ColorMapObject *MakeMapObject(int ColorCount,
0N/A const GifColorType * ColorMap);
0N/Aextern void FreeMapObject(ColorMapObject * Object);
0N/Aextern int BitSize(int n);
0N/A
0N/A/******************************************************************************
0N/A * Support for the in-core structures allocation (slurp mode).
0N/A *****************************************************************************/
0N/A
0N/A/* This is the in-core version of an extension record */
0N/Atypedef struct {
0N/A int ByteCount;
0N/A char *Bytes; /* on malloc(3) heap */
0N/A int Function; /* Holds the type of the Extension block. */
0N/A} ExtensionBlock;
0N/A
0N/A/* This holds an image header, its unpacked raster bits, and extensions */
0N/Atypedef struct SavedImage {
0N/A GifImageDesc ImageDesc;
0N/A unsigned char *RasterBits; /* on malloc(3) heap */
0N/A int Function; /* DEPRECATED: Use ExtensionBlocks[x].Function instead */
0N/A int ExtensionBlockCount;
0N/A ExtensionBlock *ExtensionBlocks; /* on malloc(3) heap */
0N/A} SavedImage;
0N/A
0N/Aextern void MakeExtension(SavedImage * New, int Function);
0N/Aextern int AddExtensionBlock(SavedImage * New, int Len,
0N/A unsigned char ExtData[]);
0N/Aextern void FreeExtension(SavedImage * Image);
0N/Aextern SavedImage *MakeSavedImage(GifFileType * GifFile,
0N/A const SavedImage * CopyFrom);
0N/Aextern void FreeSavedImages(GifFileType * GifFile);
0N/A
0N/A
0N/A#ifdef __cplusplus
0N/A}
0N/A#endif /* __cplusplus */
0N/A#endif /* _GIF_LIB_H */