Back to index

im-sdk  12.3.91
Classes | Defines | Typedefs | Enumerations | Functions | Variables
gif_lib.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  GifColorType
struct  ColorMapObject
struct  GifImageDesc
struct  GifFileType
struct  ExtensionBlock
struct  SavedImage

Defines

#define GIF_LIB_VERSION   " Version 2.0, "
#define GIF_ERROR   0
#define GIF_OK   1
#define TRUE   1
#define FALSE   0
#define NULL   0
#define GIF_FILE_BUFFER_SIZE   16384 /* Files uses bigger buffers than usual. */
#define GIF_MESSAGE(Msg)   fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg)
#define GIF_EXIT(Msg)   { GIF_MESSAGE(Msg); exit(-3); }
#define VoidPtr   void *
#define COMMENT_EXT_FUNC_CODE   0xfe /* comment */
#define GRAPHICS_EXT_FUNC_CODE   0xf9 /* graphics control */
#define PLAINTEXT_EXT_FUNC_CODE   0x01 /* plaintext */
#define APPLICATION_EXT_FUNC_CODE   0xff /* application block */
#define E_GIF_ERR_OPEN_FAILED   1 /* And EGif possible errors. */
#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
#define D_GIF_ERR_OPEN_FAILED   101 /* And DGif possible errors. */
#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
#define GIF_FONT_WIDTH   8
#define GIF_FONT_HEIGHT   8

Typedefs

typedef int GifBooleanType
typedef unsigned char GifPixelType
typedef unsigned char * GifRowType
typedef unsigned char GifByteType
typedef struct GifColorType GifColorType
typedef struct ColorMapObject ColorMapObject
typedef struct GifImageDesc GifImageDesc
typedef struct GifFileType GifFileType
typedef struct SavedImage SavedImage

Enumerations

enum  GifRecordType {
  UNDEFINED_RECORD_TYPE, SCREEN_DESC_RECORD_TYPE, IMAGE_DESC_RECORD_TYPE, EXTENSION_RECORD_TYPE,
  TERMINATE_RECORD_TYPE
}
enum  GifScreenDumpType { GIF_DUMP_SGI_WINDOW = 1000, GIF_DUMP_X_WINDOW = 1001 }

Functions

GifFileTypeEGifOpenFileName (char *GifFileName, int GifTestExistance)
GifFileTypeEGifOpenFileHandle (int GifFileHandle)
int EGifSpew (GifFileType *GifFile)
void EGifSetGifVersion (char *Version)
int EGifPutScreenDesc (GifFileType *GifFile, int GifWidth, int GifHeight, int GifColorRes, int GifBackGround, ColorMapObject *GifColorMap)
int EGifPutImageDesc (GifFileType *GifFile, int GifLeft, int GifTop, int Width, int GifHeight, int GifInterlace, ColorMapObject *GifColorMap)
int EGifPutLine (GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen)
int EGifPutPixel (GifFileType *GifFile, GifPixelType GifPixel)
int EGifPutComment (GifFileType *GifFile, char *GifComment)
int EGifPutExtension (GifFileType *GifFile, int GifExtCode, int GifExtLen, VoidPtr GifExtension)
int EGifPutCode (GifFileType *GifFile, int GifCodeSize, GifByteType *GifCodeBlock)
int EGifPutCodeNext (GifFileType *GifFile, GifByteType *GifCodeBlock)
int EGifCloseFile (GifFileType *GifFile)
GifFileTypeDGifOpenFileName (const char *GifFileName)
GifFileTypeDGifOpenFileHandle (int GifFileHandle)
int DGifSlurp (GifFileType *GifFile)
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 DGifCloseFile (GifFileType *GifFile)
int QuantizeBuffer (unsigned int Width, unsigned int Height, int *ColorMapSize, GifByteType *RedInput, GifByteType *GreenInput, GifByteType *BlueInput, GifByteType *OutputBuffer, GifColorType *OutputColorMap)
void GifQprintf (char *Format,...)
void PrintGifError (void)
int GifLastError (void)
int DumpScreen2Gif (char *FileName, int ReqGraphDriver, int ReqGraphMode1, int ReqGraphMode2, int ReqGraphMode3)
ColorMapObjectMakeMapObject (int ColorCount, GifColorType *ColorMap)
void FreeMapObject (ColorMapObject *Object)
ColorMapObjectUnionColorMap (ColorMapObject *ColorIn1, ColorMapObject *ColorIn2, GifPixelType ColorTransIn2[])
int BitSize (int n)
void ApplyTranslation (SavedImage *Image, GifPixelType Translation[])
void MakeExtension (SavedImage *New, int Function)
int AddExtensionBlock (SavedImage *New, int Len, char ExtData[])
void FreeExtension (SavedImage *Image)
SavedImageMakeSavedImage (GifFileType *GifFile, SavedImage *CopyFrom)
void FreeSavedImages (GifFileType *GifFile)
void DrawText (SavedImage *Image, const int x, const int y, const char *legend, const int color)
void DrawBox (SavedImage *Image, const int x, const int y, const int w, const int d, const int color)
void DrawRectangle (SavedImage *Image, const int x, const int y, const int w, const int d, const int color)
void DrawBoxedText (SavedImage *Image, const int x, const int y, const char *legend, const int border, const int bg, const int fg)

Variables

int GifQuietPrint
unsigned char AsciiTable [][GIF_FONT_WIDTH]

Class Documentation

struct GifColorType

Definition at line 48 of file gif_lib.h.

Class Members
GifByteType Blue
GifByteType Green
GifByteType Red
struct ColorMapObject

Definition at line 52 of file gif_lib.h.

Collaboration diagram for ColorMapObject:
Class Members
int BitsPerPixel
int ColorCount
GifColorType * Colors
struct GifImageDesc

Definition at line 60 of file gif_lib.h.

Collaboration diagram for GifImageDesc:
Class Members
ColorMapObject * ColorMap
int Height
int Interlace
int Left
int Top
int Width
struct GifFileType

Definition at line 66 of file gif_lib.h.

Collaboration diagram for GifFileType:
Class Members
GifImageDesc Image
int ImageCount
VoidPtr Private
struct SavedImage * SavedImages
int SBackGroundColor
ColorMapObject * SColorMap
int SColorResolution
int SHeight
int SWidth
struct ExtensionBlock

Definition at line 233 of file gif_lib.h.

Class Members
int ByteCount
char * Bytes
struct SavedImage

Definition at line 239 of file gif_lib.h.

Collaboration diagram for SavedImage:
Class Members
int ExtensionBlockCount
ExtensionBlock * ExtensionBlocks
int Function
GifImageDesc ImageDesc
char * RasterBits

Define Documentation

#define APPLICATION_EXT_FUNC_CODE   0xff /* application block */

Definition at line 101 of file gif_lib.h.

#define COMMENT_EXT_FUNC_CODE   0xfe /* comment */

Definition at line 98 of file gif_lib.h.

#define D_GIF_ERR_CLOSE_FAILED   110

Definition at line 171 of file gif_lib.h.

#define D_GIF_ERR_DATA_TOO_BIG   108

Definition at line 169 of file gif_lib.h.

#define D_GIF_ERR_EOF_TOO_SOON   113

Definition at line 174 of file gif_lib.h.

#define D_GIF_ERR_IMAGE_DEFECT   112

Definition at line 173 of file gif_lib.h.

#define D_GIF_ERR_NO_COLOR_MAP   106

Definition at line 167 of file gif_lib.h.

#define D_GIF_ERR_NO_IMAG_DSCR   105

Definition at line 166 of file gif_lib.h.

#define D_GIF_ERR_NO_SCRN_DSCR   104

Definition at line 165 of file gif_lib.h.

#define D_GIF_ERR_NOT_ENOUGH_MEM   109

Definition at line 170 of file gif_lib.h.

#define D_GIF_ERR_NOT_GIF_FILE   103

Definition at line 164 of file gif_lib.h.

#define D_GIF_ERR_NOT_READABLE   111

Definition at line 172 of file gif_lib.h.

#define D_GIF_ERR_OPEN_FAILED   101 /* And DGif possible errors. */

Definition at line 162 of file gif_lib.h.

#define D_GIF_ERR_READ_FAILED   102

Definition at line 163 of file gif_lib.h.

#define D_GIF_ERR_WRONG_RECORD   107

Definition at line 168 of file gif_lib.h.

#define E_GIF_ERR_CLOSE_FAILED   9

Definition at line 136 of file gif_lib.h.

#define E_GIF_ERR_DATA_TOO_BIG   6

Definition at line 133 of file gif_lib.h.

#define E_GIF_ERR_DISK_IS_FULL   8

Definition at line 135 of file gif_lib.h.

#define E_GIF_ERR_HAS_IMAG_DSCR   4

Definition at line 131 of file gif_lib.h.

#define E_GIF_ERR_HAS_SCRN_DSCR   3

Definition at line 130 of file gif_lib.h.

#define E_GIF_ERR_NO_COLOR_MAP   5

Definition at line 132 of file gif_lib.h.

#define E_GIF_ERR_NOT_ENOUGH_MEM   7

Definition at line 134 of file gif_lib.h.

#define E_GIF_ERR_NOT_WRITEABLE   10

Definition at line 137 of file gif_lib.h.

#define E_GIF_ERR_OPEN_FAILED   1 /* And EGif possible errors. */

Definition at line 128 of file gif_lib.h.

#define E_GIF_ERR_WRITE_FAILED   2

Definition at line 129 of file gif_lib.h.

#define FALSE   0

Definition at line 25 of file gif_lib.h.

#define GIF_ERROR   0

Definition at line 20 of file gif_lib.h.

#define GIF_EXIT (   Msg)    { GIF_MESSAGE(Msg); exit(-3); }

Definition at line 40 of file gif_lib.h.

#define GIF_FILE_BUFFER_SIZE   16384 /* Files uses bigger buffers than usual. */

Definition at line 32 of file gif_lib.h.

#define GIF_FONT_HEIGHT   8

Definition at line 263 of file gif_lib.h.

#define GIF_FONT_WIDTH   8

Definition at line 262 of file gif_lib.h.

#define GIF_LIB_VERSION   " Version 2.0, "

Definition at line 18 of file gif_lib.h.

#define GIF_MESSAGE (   Msg)    fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg)

Definition at line 39 of file gif_lib.h.

#define GIF_OK   1

Definition at line 21 of file gif_lib.h.

#define GRAPHICS_EXT_FUNC_CODE   0xf9 /* graphics control */

Definition at line 99 of file gif_lib.h.

#define NULL   0

Definition at line 29 of file gif_lib.h.

#define PLAINTEXT_EXT_FUNC_CODE   0x01 /* plaintext */

Definition at line 100 of file gif_lib.h.

#define TRUE   1

Definition at line 24 of file gif_lib.h.

#define VoidPtr   void *

Definition at line 45 of file gif_lib.h.


Typedef Documentation

typedef int GifBooleanType

Definition at line 34 of file gif_lib.h.

typedef unsigned char GifByteType

Definition at line 37 of file gif_lib.h.

typedef struct GifColorType GifColorType
typedef struct GifFileType GifFileType
typedef struct GifImageDesc GifImageDesc
typedef unsigned char GifPixelType

Definition at line 35 of file gif_lib.h.

typedef unsigned char* GifRowType

Definition at line 36 of file gif_lib.h.

typedef struct SavedImage SavedImage

Enumeration Type Documentation

Enumerator:
UNDEFINED_RECORD_TYPE 
SCREEN_DESC_RECORD_TYPE 
IMAGE_DESC_RECORD_TYPE 
EXTENSION_RECORD_TYPE 
TERMINATE_RECORD_TYPE 

Definition at line 77 of file gif_lib.h.

Enumerator:
GIF_DUMP_SGI_WINDOW 
GIF_DUMP_X_WINDOW 

Definition at line 89 of file gif_lib.h.


Function Documentation

int AddExtensionBlock ( SavedImage New,
int  Len,
char  ExtData[] 
)

Definition at line 212 of file gifalloc.c.

{
    ExtensionBlock   *ep;

    if (New->ExtensionBlocks == NULL)
       New->ExtensionBlocks = (ExtensionBlock *)malloc(sizeof(ExtensionBlock));
    else
       New->ExtensionBlocks =
           (ExtensionBlock *)realloc(New->ExtensionBlocks,
                    sizeof(ExtensionBlock) * (New->ExtensionBlockCount + 1));

    if (New->ExtensionBlocks == NULL)
       return(GIF_ERROR);

    ep = &New->ExtensionBlocks[New->ExtensionBlockCount++];

    if ((ep->Bytes = (char *)malloc(ep->ByteCount = Len)) == NULL)
       return(GIF_ERROR);

    if (ExtData)
       memcpy(ep->Bytes, ExtData, Len);

    return(GIF_OK);
}
void ApplyTranslation ( SavedImage Image,
GifPixelType  Translation[] 
)

Definition at line 188 of file gifalloc.c.

{
    register int i;
    register int RasterSize = Image->ImageDesc.Height * Image->ImageDesc.Width;

    for (i = 0; i < RasterSize; i++)
       Image->RasterBits[i] = Translation[Image->RasterBits[i]];
}
int BitSize ( int  n)

Definition at line 21 of file gifalloc.c.

{
    register  i;

    for (i = 1; i <= 8; i++)
       if ((1 << i) >= n)
           break;
    return(i);
}

Here is the caller graph for this function:

int DGifCloseFile ( GifFileType GifFile)

Definition at line 478 of file dgif_lib.c.

{
    GifFilePrivateType *Private;
    FILE *File;

    if (GifFile == NULL) return GIF_ERROR;

    Private = (GifFilePrivateType *) GifFile->Private;

    if (!IS_READABLE(Private)) {
       /* This file was NOT open for reading: */
       _GifError = D_GIF_ERR_NOT_READABLE;
       return GIF_ERROR;
    }

    File = Private->File;

    if (GifFile->Image.ColorMap)
       FreeMapObject(GifFile->Image.ColorMap);
    if (GifFile->SColorMap)
       FreeMapObject(GifFile->SColorMap);
    if (Private)
       free((char *) Private);
    if (GifFile->SavedImages)
       FreeSavedImages(GifFile);
    free(GifFile);

    if (fclose(File) != 0) {
       _GifError = D_GIF_ERR_CLOSE_FAILED;
       return GIF_ERROR;
    }
    return GIF_OK;
}

Here is the call graph for this function:

int DGifGetCode ( GifFileType GifFile,
int *  GifCodeSize,
GifByteType **  GifCodeBlock 
)

Definition at line 535 of file dgif_lib.c.

{
    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;

    if (!IS_READABLE(Private)) {
       /* This file was NOT open for reading: */
       _GifError = D_GIF_ERR_NOT_READABLE;
       return GIF_ERROR;
    }

    *CodeSize = Private->BitsPerPixel;

    return DGifGetCodeNext(GifFile, CodeBlock);
}

Here is the call graph for this function:

int DGifGetCodeNext ( GifFileType GifFile,
GifByteType **  GifCodeBlock 
)

Definition at line 555 of file dgif_lib.c.

{
    GifByteType Buf;
    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;

    if (fread(&Buf, 1, 1, Private->File) != 1) {
       _GifError = D_GIF_ERR_READ_FAILED;
       return GIF_ERROR;
    }

    if (Buf > 0) {
       *CodeBlock = Private->Buf;         /* Use private unused buffer. */
       (*CodeBlock)[0] = Buf;  /* Pascal strings notation (pos. 0 is len.). */
       if (fread(&((*CodeBlock)[1]), 1, Buf, Private->File) != Buf) {
           _GifError = D_GIF_ERR_READ_FAILED;
           return GIF_ERROR;
       }
    }
    else {
       *CodeBlock = NULL;
       Private->Buf[0] = 0;           /* Make sure the buffer is empty! */
       Private->PixelCount = 0;   /* And local info. indicate image read. */
    }

    return GIF_OK;
}

Here is the caller graph for this function:

int DGifGetComment ( GifFileType GifFile,
char *  GifComment 
)
int DGifGetExtension ( GifFileType GifFile,
int *  GifExtCode,
GifByteType **  GifExtension 
)

Definition at line 426 of file dgif_lib.c.

{
    GifByteType Buf;
    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;

    if (!IS_READABLE(Private)) {
       /* This file was NOT open for reading: */
       _GifError = D_GIF_ERR_NOT_READABLE;
       return GIF_ERROR;
    }

    if (fread(&Buf, 1, 1, Private->File) != 1) {
       _GifError = D_GIF_ERR_READ_FAILED;
       return GIF_ERROR;
    }
    *ExtCode = Buf;

    return DGifGetExtensionNext(GifFile, Extension);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int DGifGetExtensionNext ( GifFileType GifFile,
GifByteType **  GifExtension 
)

Definition at line 452 of file dgif_lib.c.

{
    GifByteType Buf;
    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;

    if (fread(&Buf, 1, 1, Private->File) != 1) {
       _GifError = D_GIF_ERR_READ_FAILED;
       return GIF_ERROR;
    }
    if (Buf > 0) {
       *Extension = Private->Buf;           /* Use private unused buffer. */
       (*Extension)[0] = Buf;  /* Pascal strings notation (pos. 0 is len.). */
       if (fread(&((*Extension)[1]), 1, Buf, Private->File) != Buf) {
           _GifError = D_GIF_ERR_READ_FAILED;
           return GIF_ERROR;
       }
    }
    else
       *Extension = NULL;

    return GIF_OK;
}

Here is the caller graph for this function:

int DGifGetImageDesc ( GifFileType GifFile)

Definition at line 272 of file dgif_lib.c.

{
    int i, BitsPerPixel;
    GifByteType Buf[3];
    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;

    if (!IS_READABLE(Private)) {
       /* This file was NOT open for reading: */
       _GifError = D_GIF_ERR_NOT_READABLE;
       return GIF_ERROR;
    }

    if (DGifGetWord(Private->File, &GifFile->Image.Left) == GIF_ERROR ||
       DGifGetWord(Private->File, &GifFile->Image.Top) == GIF_ERROR ||
       DGifGetWord(Private->File, &GifFile->Image.Width) == GIF_ERROR ||
       DGifGetWord(Private->File, &GifFile->Image.Height) == GIF_ERROR)
       return GIF_ERROR;
    if (fread(Buf, 1, 1, Private->File) != 1) {
       _GifError = D_GIF_ERR_READ_FAILED;
       return GIF_ERROR;
    }
    BitsPerPixel = (Buf[0] & 0x07) + 1;
    GifFile->Image.Interlace = (Buf[0] & 0x40);
    if (Buf[0] & 0x80) {        /* Does this image have local color map? */

       if (GifFile->Image.ColorMap && GifFile->SavedImages == NULL)
           FreeMapObject(GifFile->Image.ColorMap);

       GifFile->Image.ColorMap = MakeMapObject(1 << BitsPerPixel, NULL);
    
       /* Get the image local color map: */
       for (i = 0; i < GifFile->Image.ColorMap->ColorCount; i++) {
           if (fread(Buf, 1, 3, Private->File) != 3) {
              _GifError = D_GIF_ERR_READ_FAILED;
              return GIF_ERROR;
           }
           GifFile->Image.ColorMap->Colors[i].Red = Buf[0];
           GifFile->Image.ColorMap->Colors[i].Green = Buf[1];
           GifFile->Image.ColorMap->Colors[i].Blue = Buf[2];
       }
    }

    if (GifFile->SavedImages) {
       SavedImage    *sp;

       if ((GifFile->SavedImages = (SavedImage *)realloc(GifFile->SavedImages,
                  sizeof(SavedImage) * (GifFile->ImageCount + 1))) == NULL) {
           _GifError = D_GIF_ERR_NOT_ENOUGH_MEM;
           return GIF_ERROR;
       }

       sp = &GifFile->SavedImages[GifFile->ImageCount];
       memcpy(&sp->ImageDesc, &GifFile->Image, sizeof(GifImageDesc));
       sp->RasterBits = (char *)NULL;
       sp->ExtensionBlockCount = 0;
       sp->ExtensionBlocks = (ExtensionBlock *)NULL;
    }

    GifFile->ImageCount++;

    Private->PixelCount = (long) GifFile->Image.Width *
                         (long) GifFile->Image.Height;

    DGifSetupDecompress(GifFile);  /* Reset decompress algorithm parameters. */

    return GIF_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int DGifGetLine ( GifFileType GifFile,
GifPixelType GifLine,
int  GifLineLen 
)

Definition at line 343 of file dgif_lib.c.

{
    GifByteType *Dummy;
    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;

    if (!IS_READABLE(Private)) {
       /* This file was NOT open for reading: */
       _GifError = D_GIF_ERR_NOT_READABLE;
       return GIF_ERROR;
    }

    if (!LineLen) LineLen = GifFile->Image.Width;

#if defined(__MSDOS__) || defined(__GNUC__)
    if ((Private->PixelCount -= LineLen) > 0xffff0000UL) {
#else
    if ((Private->PixelCount -= LineLen) > 0xffff0000) {
#endif /* __MSDOS__ */
       _GifError = D_GIF_ERR_DATA_TOO_BIG;
       return GIF_ERROR;
    }

    if (DGifDecompressLine(GifFile, Line, LineLen) == GIF_OK) {
       if (Private->PixelCount == 0) {
           /* We probably would not be called any more, so lets clean             */
           /* everything before we return: need to flush out all rest of    */
           /* image until empty block (size 0) detected. We use GetCodeNext.*/
           do if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR)
              return GIF_ERROR;
           while (Dummy != NULL);
       }
       return GIF_OK;
    }
    else
       return GIF_ERROR;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int DGifGetLZCodes ( GifFileType GifFile,
int *  GifCode 
)

Definition at line 761 of file dgif_lib.c.

{
    GifByteType *CodeBlock;
    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;

    if (!IS_READABLE(Private)) {
       /* This file was NOT open for reading: */
       _GifError = D_GIF_ERR_NOT_READABLE;
       return GIF_ERROR;
    }

    if (DGifDecompressInput(Private, Code) == GIF_ERROR)
       return GIF_ERROR;

    if (*Code == Private->EOFCode) {
       /* Skip rest of codes (hopefully only NULL terminating block): */
       do if (DGifGetCodeNext(GifFile, &CodeBlock) == GIF_ERROR)
           return GIF_ERROR;
       while (CodeBlock != NULL);

       *Code = -1;
    }
    else if (*Code == Private->ClearCode) {
       /* We need to start over again: */
       Private->RunningCode = Private->EOFCode + 1;
       Private->RunningBits = Private->BitsPerPixel + 1;
       Private->MaxCode1 = 1 << Private->RunningBits;
    }

    return GIF_OK;
}

Here is the call graph for this function:

int DGifGetPixel ( GifFileType GifFile,
GifPixelType  GifPixel 
)

Definition at line 383 of file dgif_lib.c.

{
    GifByteType *Dummy;
    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;

    if (!IS_READABLE(Private)) {
       /* This file was NOT open for reading: */
       _GifError = D_GIF_ERR_NOT_READABLE;
       return GIF_ERROR;
    }

#if defined(__MSDOS__) || defined(__GNUC__)
    if (--Private->PixelCount > 0xffff0000UL)
#else
    if (--Private->PixelCount > 0xffff0000)
#endif /* __MSDOS__ */
    {
       _GifError = D_GIF_ERR_DATA_TOO_BIG;
       return GIF_ERROR;
    }

    if (DGifDecompressLine(GifFile, &Pixel, 1) == GIF_OK) {
       if (Private->PixelCount == 0) {
           /* We probably would not be called any more, so lets clean             */
           /* everything before we return: need to flush out all rest of    */
           /* image until empty block (size 0) detected. We use GetCodeNext.*/
           do if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR)
              return GIF_ERROR;
           while (Dummy != NULL);
       }
       return GIF_OK;
    }
    else
       return GIF_ERROR;
}

Here is the call graph for this function:

int DGifGetRecordType ( GifFileType GifFile,
GifRecordType GifType 
)

Definition at line 233 of file dgif_lib.c.

{
    GifByteType Buf;
    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;

    if (!IS_READABLE(Private)) {
       /* This file was NOT open for reading: */
       _GifError = D_GIF_ERR_NOT_READABLE;
       return GIF_ERROR;
    }

    if (fread(&Buf, 1, 1, Private->File) != 1) {
       _GifError = D_GIF_ERR_READ_FAILED;
       return GIF_ERROR;
    }

    switch (Buf) {
       case ',':
           *Type = IMAGE_DESC_RECORD_TYPE;
           break;
       case '!':
           *Type = EXTENSION_RECORD_TYPE;
           break;
       case ';':
           *Type = TERMINATE_RECORD_TYPE;
           break;
       default:
           *Type = UNDEFINED_RECORD_TYPE;
           _GifError = D_GIF_ERR_WRONG_RECORD;
           return GIF_ERROR;
    }

    return GIF_OK;
}

Here is the caller graph for this function:

int DGifGetScreenDesc ( GifFileType GifFile)

Definition at line 187 of file dgif_lib.c.

{
    int i, BitsPerPixel;
    GifByteType Buf[3];
    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;

    if (!IS_READABLE(Private)) {
       /* This file was NOT open for reading: */
       _GifError = D_GIF_ERR_NOT_READABLE;
       return GIF_ERROR;
    }

    /* Put the screen descriptor into the file: */
    if (DGifGetWord(Private->File, &GifFile->SWidth) == GIF_ERROR ||
       DGifGetWord(Private->File, &GifFile->SHeight) == GIF_ERROR)
       return GIF_ERROR;

    if (fread(Buf, 1, 3, Private->File) != 3) {
       _GifError = D_GIF_ERR_READ_FAILED;
       return GIF_ERROR;
    }
    GifFile->SColorResolution = (((Buf[0] & 0x70) + 1) >> 4) + 1;
    BitsPerPixel = (Buf[0] & 0x07) + 1;
    GifFile->SBackGroundColor = Buf[1];
    if (Buf[0] & 0x80) {                /* Do we have global color map? */

       GifFile->SColorMap = MakeMapObject(1 << BitsPerPixel, NULL);

       /* Get the global color map: */
       for (i = 0; i < GifFile->SColorMap->ColorCount; i++) {
           if (fread(Buf, 1, 3, Private->File) != 3) {
              _GifError = D_GIF_ERR_READ_FAILED;
              return GIF_ERROR;
           }
           GifFile->SColorMap->Colors[i].Red = Buf[0];
           GifFile->SColorMap->Colors[i].Green = Buf[1];
           GifFile->SColorMap->Colors[i].Blue = Buf[2];
       }
    }

    return GIF_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GifFileType* DGifOpenFileHandle ( int  GifFileHandle)

Definition at line 121 of file dgif_lib.c.

{
    char Buf[GIF_STAMP_LEN+1];
    GifFileType *GifFile;
    GifFilePrivateType *Private;
    FILE *f;

#ifdef __MSDOS__
    setmode(FileHandle, O_BINARY);   /* Make sure it is in binary mode. */
    f = fdopen(FileHandle, "rb");            /* Make it into a stream: */
    setvbuf(f, NULL, _IOFBF, GIF_FILE_BUFFER_SIZE);/* And inc. stream buffer.*/
#else
    f = fdopen(FileHandle, "r");             /* Make it into a stream: */
#endif /* __MSDOS__ */

    if ((GifFile = (GifFileType *) malloc(sizeof(GifFileType))) == NULL) {
       _GifError = D_GIF_ERR_NOT_ENOUGH_MEM;
       return NULL;
    }

    memset(GifFile, '\0', sizeof(GifFileType));

    if ((Private = (GifFilePrivateType *) malloc(sizeof(GifFilePrivateType)))
       == NULL) {
       _GifError = D_GIF_ERR_NOT_ENOUGH_MEM;
       free((char *) GifFile);
       return NULL;
    }
    GifFile->Private = (VoidPtr) Private;
    Private->FileHandle = FileHandle;
    Private->File = f;
    Private->FileState = 0;   /* Make sure bit 0 = 0 (File open for read). */

    /* Lets see if this is a GIF file: */
    if (fread(Buf, 1, GIF_STAMP_LEN, Private->File) != GIF_STAMP_LEN) {
       _GifError = D_GIF_ERR_READ_FAILED;
       free((char *) Private);
       free((char *) GifFile);
       return NULL;
    }

    /* The GIF Version number is ignored at this time. Maybe we should do    */
    /* something more useful with it.                                      */
    Buf[GIF_STAMP_LEN] = 0;
    if (strncmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) {
       _GifError = D_GIF_ERR_NOT_GIF_FILE;
       free((char *) Private);
       free((char *) GifFile);
       return NULL;
    }

    if (DGifGetScreenDesc(GifFile) == GIF_ERROR) {
       free((char *) Private);
       free((char *) GifFile);
       return NULL;
    }

    _GifError = 0;

    return GifFile;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GifFileType* DGifOpenFileName ( const char *  GifFileName)

Definition at line 100 of file dgif_lib.c.

{
    int FileHandle;

    if ((FileHandle = open(FileName, O_RDONLY
#ifdef __MSDOS__
                                | O_BINARY
#endif /* __MSDOS__ */
                                          )) == -1) {
       _GifError = D_GIF_ERR_OPEN_FAILED;
       return NULL;
    }

    return DGifOpenFileHandle(FileHandle);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int DGifSlurp ( GifFileType GifFile)

Definition at line 872 of file dgif_lib.c.

{
    int i, j, Error, ImageSize;
    GifRecordType RecordType;
    SavedImage *sp;
    ExtensionBlock *ep;
    GifByteType *ExtData;

    /* Some versions of malloc dislike 0-length requests */
    GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage));

    do {
       if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR)
           return(GIF_ERROR);

       switch (RecordType) {
           case IMAGE_DESC_RECORD_TYPE:
              if (DGifGetImageDesc(GifFile) == GIF_ERROR)
                  return(GIF_ERROR);

              sp = &GifFile->SavedImages[GifFile->ImageCount-1];
              ImageSize = sp->ImageDesc.Width * sp->ImageDesc.Height;

              sp->RasterBits
                  = (GifPixelType*) malloc(ImageSize * sizeof(GifPixelType));

              if (DGifGetLine(GifFile, sp->RasterBits, ImageSize)
                  == GIF_ERROR)
                  return(GIF_ERROR);

              break;

           case EXTENSION_RECORD_TYPE:

              if (DGifGetExtension(GifFile,&sp->Function,&ExtData)==GIF_ERROR)
                  return(GIF_ERROR);
              else
              {
                  ep = &sp->ExtensionBlocks[sp->ExtensionBlockCount++];

                  ep->ByteCount = ExtData[0];
                  ep->Bytes = (GifByteType *)malloc(ep->ByteCount * sizeof(GifByteType));
                  memcpy(ep->Bytes, ExtData, ep->ByteCount * sizeof(char));
              }

              while (ExtData != NULL) {
                  if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR)
                     return(GIF_ERROR);
                  else
                  {
                     ep = &sp->ExtensionBlocks[sp->ExtensionBlockCount++];

                     ep->ByteCount = ExtData[0];
                     ep->Bytes = (GifByteType *)malloc(ep->ByteCount * sizeof(GifByteType));
                     memcpy(ep->Bytes,ExtData,ep->ByteCount * sizeof(char));
                  }
              }
              break;

           case TERMINATE_RECORD_TYPE:
              break;

           default:  /* Should be trapped by DGifGetRecordType */
              break;
       }
    }
    while
       (RecordType != TERMINATE_RECORD_TYPE);

    return(GIF_OK);
}

Here is the call graph for this function:

void DrawBox ( SavedImage Image,
const int  x,
const int  y,
const int  w,
const int  d,
const int  color 
)
void DrawBoxedText ( SavedImage Image,
const int  x,
const int  y,
const char *  legend,
const int  border,
const int  bg,
const int  fg 
)
void DrawRectangle ( SavedImage Image,
const int  x,
const int  y,
const int  w,
const int  d,
const int  color 
)
void DrawText ( SavedImage Image,
const int  x,
const int  y,
const char *  legend,
const int  color 
)
int DumpScreen2Gif ( char *  FileName,
int  ReqGraphDriver,
int  ReqGraphMode1,
int  ReqGraphMode2,
int  ReqGraphMode3 
)
int EGifCloseFile ( GifFileType GifFile)
GifFileType* EGifOpenFileHandle ( int  GifFileHandle)
GifFileType* EGifOpenFileName ( char *  GifFileName,
int  GifTestExistance 
)
int EGifPutCode ( GifFileType GifFile,
int  GifCodeSize,
GifByteType GifCodeBlock 
)
int EGifPutCodeNext ( GifFileType GifFile,
GifByteType GifCodeBlock 
)
int EGifPutComment ( GifFileType GifFile,
char *  GifComment 
)
int EGifPutExtension ( GifFileType GifFile,
int  GifExtCode,
int  GifExtLen,
VoidPtr  GifExtension 
)
int EGifPutImageDesc ( GifFileType GifFile,
int  GifLeft,
int  GifTop,
int  Width,
int  GifHeight,
int  GifInterlace,
ColorMapObject GifColorMap 
)
int EGifPutLine ( GifFileType GifFile,
GifPixelType GifLine,
int  GifLineLen 
)
int EGifPutPixel ( GifFileType GifFile,
GifPixelType  GifPixel 
)
int EGifPutScreenDesc ( GifFileType GifFile,
int  GifWidth,
int  GifHeight,
int  GifColorRes,
int  GifBackGround,
ColorMapObject GifColorMap 
)
void EGifSetGifVersion ( char *  Version)
int EGifSpew ( GifFileType GifFile)
void FreeExtension ( SavedImage Image)

Definition at line 237 of file gifalloc.c.

{
    ExtensionBlock   *ep;

    for (ep = Image->ExtensionBlocks;
        ep < Image->ExtensionBlocks + Image->ExtensionBlockCount;
        ep++)
       (void) free((char *)ep->Bytes);
    free((char *)Image->ExtensionBlocks);
    Image->ExtensionBlocks = NULL;
}

Here is the caller graph for this function:

void FreeMapObject ( ColorMapObject Object)

Definition at line 66 of file gifalloc.c.

{
    free(Object->Colors);
    free(Object);
}

Here is the caller graph for this function:

void FreeSavedImages ( GifFileType GifFile)

Definition at line 320 of file gifalloc.c.

{
    SavedImage       *sp;

    for (sp = GifFile->SavedImages;
        sp < GifFile->SavedImages + GifFile->ImageCount;
        sp++)
    {
       if (sp->ImageDesc.ColorMap)
           FreeMapObject(sp->ImageDesc.ColorMap);

       if (sp->RasterBits)
           free((char *)sp->RasterBits);

       if (sp->ExtensionBlocks)
           FreeExtension(sp);
    }
    free((char *) GifFile->SavedImages);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int GifLastError ( void  )

Definition at line 36 of file gif_err.c.

{
    int i = _GifError;

    _GifError = 0;

    return i;
}
void GifQprintf ( char *  Format,
  ... 
)
void MakeExtension ( SavedImage New,
int  Function 
)

Definition at line 204 of file gifalloc.c.

{
    New->Function = Function;
    /*
     * Someday we might have to deal with multiple extensions.
     */
}
ColorMapObject* MakeMapObject ( int  ColorCount,
GifColorType ColorMap 
)

Definition at line 37 of file gifalloc.c.

{
    ColorMapObject *Object;

    if (ColorCount != (1 << BitSize(ColorCount)))
       return((ColorMapObject *)NULL);

    Object = (ColorMapObject *)malloc(sizeof(ColorMapObject));
    if (Object == (ColorMapObject *)NULL)
       return((ColorMapObject *)NULL);

    Object->Colors = (GifColorType *)calloc(ColorCount, sizeof(GifColorType));
    if (Object->Colors == (GifColorType *)NULL)
       return((ColorMapObject *)NULL);

    Object->ColorCount = ColorCount;
    Object->BitsPerPixel = BitSize(ColorCount);

    if (ColorMap)
       memcpy((char *)Object->Colors,
              (char *)ColorMap, ColorCount * sizeof(GifColorType));

    return(Object);
}

Here is the call graph for this function:

Here is the caller graph for this function:

SavedImage* MakeSavedImage ( GifFileType GifFile,
SavedImage CopyFrom 
)

Definition at line 252 of file gifalloc.c.

{
    SavedImage       *sp;

    if (GifFile->SavedImages == NULL)
       GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage));
    else
       GifFile->SavedImages = (SavedImage *)realloc(GifFile->SavedImages,
                            sizeof(SavedImage) * (GifFile->ImageCount+1));

    if (GifFile->SavedImages == NULL)
       return((SavedImage *)NULL);
    else
    {
       sp = &GifFile->SavedImages[GifFile->ImageCount++];
       memset((char *)sp, '\0', sizeof(SavedImage));

       if (CopyFrom)
       {
           memcpy((char *)sp, CopyFrom, sizeof(SavedImage));

           /*
            * Make our own allocated copies of the heap fields in the
            * copied record.  This guards against potential aliasing
            * problems.
            */

           /* first, the local color map */
           if (sp->ImageDesc.ColorMap)
              sp->ImageDesc.ColorMap =
                  MakeMapObject(CopyFrom->ImageDesc.ColorMap->ColorCount,
                              CopyFrom->ImageDesc.ColorMap->Colors);

           /* next, the raster */
           sp->RasterBits = (char *)malloc(sizeof(GifPixelType)
                            * CopyFrom->ImageDesc.Height
                            * CopyFrom->ImageDesc.Width);
           memcpy(sp->RasterBits,
                 CopyFrom->RasterBits,
                 sizeof(GifPixelType)
                     * CopyFrom->ImageDesc.Height
                     * CopyFrom->ImageDesc.Width);

           /* finally, the extension blocks */
           if (sp->ExtensionBlocks)
           {
              sp->ExtensionBlocks
                  = (ExtensionBlock*)malloc(sizeof(ExtensionBlock)
                                         * CopyFrom->ExtensionBlockCount);
              memcpy(sp->ExtensionBlocks,
                 CopyFrom->ExtensionBlocks,
                 sizeof(ExtensionBlock)
                     * CopyFrom->ExtensionBlockCount);

              /*
               * For the moment, the actual blocks can take their
               * chances with free().  We'll fix this later. 
               */
           }
       }

       return(sp);
    }
}

Here is the call graph for this function:

void PrintGifError ( void  )

Definition at line 48 of file gif_err.c.

{
    char *Err;

    switch(_GifError) {
       case E_GIF_ERR_OPEN_FAILED:
           Err = "Failed to open given file";
           break;
       case E_GIF_ERR_WRITE_FAILED:
           Err = "Failed to Write to given file";
           break;
       case E_GIF_ERR_HAS_SCRN_DSCR:
           Err = "Screen Descriptor already been set";
           break;
       case E_GIF_ERR_HAS_IMAG_DSCR:
           Err = "Image Descriptor is still active";
           break;
       case E_GIF_ERR_NO_COLOR_MAP:
           Err = "Neither Global Nor Local color map";
           break;
       case E_GIF_ERR_DATA_TOO_BIG:
           Err = "#Pixels bigger than Width * Height";
           break;
       case E_GIF_ERR_NOT_ENOUGH_MEM:
           Err = "Fail to allocate required memory";
           break;
       case E_GIF_ERR_DISK_IS_FULL:
           Err = "Write failed (disk full?)";
           break;
       case E_GIF_ERR_CLOSE_FAILED:
           Err = "Failed to close given file";
           break;
       case E_GIF_ERR_NOT_WRITEABLE:
           Err = "Given file was not opened for write";
           break;
       case D_GIF_ERR_OPEN_FAILED:
           Err = "Failed to open given file";
           break;
       case D_GIF_ERR_READ_FAILED:
           Err = "Failed to Read from given file";
           break;
       case D_GIF_ERR_NOT_GIF_FILE:
           Err = "Given file is NOT GIF file";
           break;
       case D_GIF_ERR_NO_SCRN_DSCR:
           Err = "No Screen Descriptor detected";
           break;
       case D_GIF_ERR_NO_IMAG_DSCR:
           Err = "No Image Descriptor detected";
           break;
       case D_GIF_ERR_NO_COLOR_MAP:
           Err = "Neither Global Nor Local color map";
           break;
       case D_GIF_ERR_WRONG_RECORD:
           Err = "Wrong record type detected";
           break;
       case D_GIF_ERR_DATA_TOO_BIG:
           Err = "#Pixels bigger than Width * Height";
           break;
       case D_GIF_ERR_NOT_ENOUGH_MEM:
           Err = "Fail to allocate required memory";
           break;
       case D_GIF_ERR_CLOSE_FAILED:
           Err = "Failed to close given file";
           break;
       case D_GIF_ERR_NOT_READABLE:
           Err = "Given file was not opened for read";
           break;
       case D_GIF_ERR_IMAGE_DEFECT:
           Err = "Image is defective, decoding aborted";
           break;
       case D_GIF_ERR_EOF_TOO_SOON:
           Err = "Image EOF detected, before image complete";
           break;
       default:
           Err = NULL;
           break;
    }
    if (Err != NULL)
       fprintf(stderr, "\nGIF-LIB error: %s.\n", Err);
    else
       fprintf(stderr, "\nGIF-LIB undefined error %d.\n", _GifError);
}

Here is the caller graph for this function:

int QuantizeBuffer ( unsigned int  Width,
unsigned int  Height,
int *  ColorMapSize,
GifByteType RedInput,
GifByteType GreenInput,
GifByteType BlueInput,
GifByteType OutputBuffer,
GifColorType OutputColorMap 
)
ColorMapObject* UnionColorMap ( ColorMapObject ColorIn1,
ColorMapObject ColorIn2,
GifPixelType  ColorTransIn2[] 
)

Definition at line 96 of file gifalloc.c.

{
    int i, j, CrntSlot, RoundUpTo, NewBitSize;
    ColorMapObject *ColorUnion;

    /*
     * Allocate table which will hold the result for sure.
     */
    ColorUnion
       = MakeMapObject(MAX(ColorIn1->ColorCount,ColorIn2->ColorCount)*2,NULL);

    if (ColorUnion == NULL)
       return(NULL);

    /* Copy ColorIn1 to ColorUnionSize; */
    for (i = 0; i < ColorIn1->ColorCount; i++)
       ColorUnion->Colors[i] = ColorIn1->Colors[i];
    CrntSlot = ColorIn1->ColorCount;

    /*
     * Potentially obnoxious hack:
     *
     * Back CrntSlot down past all contiguous {0, 0, 0} slots at the end
     * of table 1.  This is very useful if your display is limited to
     * 16 colors.
     */
    while (ColorIn1->Colors[CrntSlot-1].Red == 0
          && ColorIn1->Colors[CrntSlot-1].Green == 0
          && ColorIn1->Colors[CrntSlot-1].Red == 0)
       CrntSlot--;

    /* Copy ColorIn2 to ColorUnionSize (use old colors if they exist): */
    for (i = 0; i < ColorIn2->ColorCount && CrntSlot<=256; i++)
    {
       /* Let's see if this color already exists: */
       for (j = 0; j < ColorIn1->ColorCount; j++)
           if (memcmp(&ColorIn1->Colors[j], &ColorIn2->Colors[i], sizeof(GifColorType)) == 0)
              break;

       if (j < ColorIn1->ColorCount)
           ColorTransIn2[i] = j;   /* color exists in Color1 */
       else
       {
           /* Color is new - copy it to a new slot: */
           ColorUnion->Colors[CrntSlot] = ColorIn2->Colors[i];
           ColorTransIn2[i] = CrntSlot++;
       }
    }

    if (CrntSlot > 256)
    {
       FreeMapObject(ColorUnion);
       return((ColorMapObject *)NULL);
    }

    NewBitSize = BitSize(CrntSlot);
    RoundUpTo = (1 << NewBitSize);

    if (RoundUpTo != ColorUnion->ColorCount)
    {
       register GifColorType       *Map = ColorUnion->Colors;

       /*
        * Zero out slots up to next power of 2.
        * We know these slots exist because of the way ColorUnion's
        * start dimension was computed.
        */
       for (j = CrntSlot; j < RoundUpTo; j++)
           Map[j].Red = Map[j].Green = Map[j].Blue = 0;

       /* perhaps we can shrink the map? */
       if (RoundUpTo < ColorUnion->ColorCount)
           ColorUnion->Colors 
              = (GifColorType *)realloc(Map, sizeof(GifColorType)*RoundUpTo);
    }

    ColorUnion->ColorCount = RoundUpTo;
    ColorUnion->BitsPerPixel = NewBitSize;

    return(ColorUnion);
}

Here is the call graph for this function:


Variable Documentation

unsigned char AsciiTable[][GIF_FONT_WIDTH]