home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TIERRA40.ZIP / BEAGLE / GIF / GIF_LIB.H < prev   
C/C++ Source or Header  |  1992-05-02  |  7KB  |  167 lines

  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. *******************************************************************************
  7. * History:                                      *
  8. * 14 Jun 89 - Version 1.0 by Gershon Elber.                      *
  9. *  3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). *
  10. ******************************************************************************/
  11.  
  12. #ifndef GIF_LIB_H
  13. #define GIF_LIB_H
  14.  
  15. #define GIF_LIB_VERSION    " Version 1.1, "
  16.  
  17. #define    GIF_ERROR    0
  18. #define GIF_OK        1
  19.  
  20. #ifndef TRUE
  21. #define TRUE        1
  22. #define FALSE        0
  23. #endif
  24.  
  25. #define GIF_FILE_BUFFER_SIZE 16384  /* Files uses bigger buffers than usual. */
  26.  
  27. typedef    int        GifBooleanType;
  28. typedef    unsigned char    GifPixelType;
  29. typedef unsigned char *    GifRowType;
  30. typedef unsigned char    GifByteType;
  31.  
  32. #define GIF_MESSAGE(Msg) fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg)
  33. #define GIF_EXIT(Msg)    { GIF_MESSAGE(Msg); exit(-3); }
  34.  
  35. #ifdef SYSV
  36. #define VoidPtr char *
  37. #else
  38. #define VoidPtr void *
  39. #endif /* SYSV */
  40.  
  41. typedef struct GifColorType {
  42.     GifByteType Red, Green, Blue;
  43. } GifColorType;
  44.  
  45. /* Note entries prefixed with S are of Screen information, while entries     */
  46. /* prefixed with I are of the current defined Image.                 */
  47. typedef struct GifFileType {
  48.     int SWidth, SHeight,                   /* Screen dimensions. */
  49.     SColorResolution, SBitsPerPixel, /* How many colors can we generate? */
  50.     SBackGroundColor,        /* I hope you understand this one... */
  51.     ILeft, ITop, IWidth, IHeight,        /* Current image dimensions. */
  52.     IInterlace,                 /* Sequential/Interlaced lines. */
  53.     IBitsPerPixel;              /* How many colors this image has? */
  54.     GifColorType *SColorMap, *IColorMap;          /* NULL if not exists. */
  55.     VoidPtr Private;      /* The regular user should not mess with this one! */
  56. } GifFileType;
  57.  
  58. typedef enum {
  59.     UNDEFINED_RECORD_TYPE,
  60.     SCREEN_DESC_RECORD_TYPE,
  61.     IMAGE_DESC_RECORD_TYPE,                   /* Begin with ',' */
  62.     EXTENSION_RECORD_TYPE,                   /* Begin with '!' */
  63.     TERMINATE_RECORD_TYPE                   /* Begin with ';' */
  64. } GifRecordType;
  65.  
  66. /* DumpScreen2Gif routine constants identify type of window/screen to dump.  */
  67. /* Note all values below 1000 are reserved for the IBMPC different display   */
  68. /* devices (it has many!) and are compatible with the numbering TC2.0        */
  69. /* (Turbo C 2.0 compiler for IBM PC) gives to these devices.             */
  70. typedef enum {
  71.     GIF_DUMP_SGI_WINDOW = 1000,
  72.     GIF_DUMP_X_WINDOW = 1001
  73. } GifScreenDumpType;
  74.  
  75. /******************************************************************************
  76. * O.k. here are the routines one can access in order to encode GIF file:      *
  77. * (GIF_LIB file EGIF_LIB.C).                              *
  78. ******************************************************************************/
  79.  
  80. GifFileType *EGifOpenFileName(char *GifFileName, int GifTestExistance);
  81. GifFileType *EGifOpenFileHandle(int GifFileHandle);
  82. void EGifSetGifVersion(char *Version);
  83. int EGifPutScreenDesc(GifFileType *GifFile,
  84.     int GifWidth, int GifHeight, int GifColorRes, int GifBackGround,
  85.     int GifBitsPerPixel, GifColorType *GifColorMap);
  86. int EGifPutImageDesc(GifFileType *GifFile,
  87.     int GifLeft, int GifTop, int Width, int GifHeight, int GifInterlace,
  88.     int GifBitsPerPixel, GifColorType *GifColorMap);
  89. int EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen);
  90. int EGifPutPixel(GifFileType *GifFile, GifPixelType GifPixel);
  91. int EGifPutComment(GifFileType *GifFile, char *GifComment);
  92. int EGifPutExtension(GifFileType *GifFile, int GifExtCode, int GifExtLen,
  93.                             VoidPtr GifExtension);
  94. int EGifPutCode(GifFileType *GifFile, int GifCodeSize,
  95.                            GifByteType *GifCodeBlock);
  96. int EGifPutCodeNext(GifFileType *GifFile, GifByteType *GifCodeBlock);
  97. int EGifCloseFile(GifFileType *GifFile);
  98.  
  99. #define    E_GIF_ERR_OPEN_FAILED    1        /* And EGif possible errors. */
  100. #define    E_GIF_ERR_WRITE_FAILED    2
  101. #define E_GIF_ERR_HAS_SCRN_DSCR    3
  102. #define E_GIF_ERR_HAS_IMAG_DSCR    4
  103. #define E_GIF_ERR_NO_COLOR_MAP    5
  104. #define E_GIF_ERR_DATA_TOO_BIG    6
  105. #define E_GIF_ERR_NOT_ENOUGH_MEM 7
  106. #define E_GIF_ERR_DISK_IS_FULL    8
  107. #define E_GIF_ERR_CLOSE_FAILED    9
  108. #define E_GIF_ERR_NOT_WRITEABLE    10
  109.  
  110. /******************************************************************************
  111. * O.k. here are the routines one can access in order to decode GIF file:      *
  112. * (GIF_LIB file DGIF_LIB.C).                              *
  113. ******************************************************************************/
  114.  
  115. GifFileType *DGifOpenFileName(char *GifFileName);
  116. GifFileType *DGifOpenFileHandle(int GifFileHandle);
  117. int DGifGetScreenDesc(GifFileType *GifFile);
  118. int DGifGetRecordType(GifFileType *GifFile, GifRecordType *GifType);
  119. int DGifGetImageDesc(GifFileType *GifFile);
  120. int DGifGetLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen);
  121. int DGifGetPixel(GifFileType *GifFile, GifPixelType GifPixel);
  122. int DGifGetComment(GifFileType *GifFile, char *GifComment);
  123. int DGifGetExtension(GifFileType *GifFile, int *GifExtCode,
  124.                         GifByteType **GifExtension);
  125. int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **GifExtension);
  126. int DGifGetCode(GifFileType *GifFile, int *GifCodeSize,
  127.                         GifByteType **GifCodeBlock);
  128. int DGifGetCodeNext(GifFileType *GifFile, GifByteType **GifCodeBlock);
  129. int DGifGetLZCodes(GifFileType *GifFile, int *GifCode);
  130. int DGifCloseFile(GifFileType *GifFile);
  131.  
  132. #define    D_GIF_ERR_OPEN_FAILED    101        /* And DGif possible errors. */
  133. #define    D_GIF_ERR_READ_FAILED    102
  134. #define    D_GIF_ERR_NOT_GIF_FILE    103
  135. #define D_GIF_ERR_NO_SCRN_DSCR    104
  136. #define D_GIF_ERR_NO_IMAG_DSCR    105
  137. #define D_GIF_ERR_NO_COLOR_MAP    106
  138. #define D_GIF_ERR_WRONG_RECORD    107
  139. #define D_GIF_ERR_DATA_TOO_BIG    108
  140. #define D_GIF_ERR_NOT_ENOUGH_MEM 109
  141. #define D_GIF_ERR_CLOSE_FAILED    110
  142. #define D_GIF_ERR_NOT_READABLE    111
  143. #define D_GIF_ERR_IMAGE_DEFECT    112
  144. #define D_GIF_ERR_EOF_TOO_SOON    113
  145.  
  146. /******************************************************************************
  147. * O.k. here are the routines from GIF_LIB file QUANTIZE.C.              *
  148. ******************************************************************************/
  149. int QuantizeBuffer(int Width, int Height, int *ColorMapSize,
  150.     GifByteType *RedInput, GifByteType *GreenInput, GifByteType *BlueInput,
  151.     GifByteType *OutputBuffer, GifColorType *OutputColorMap);
  152.  
  153. /******************************************************************************
  154. * O.k. here are the routines from GIF_LIB file GIF_ERR.C.              *
  155. ******************************************************************************/
  156. void PrintGifError(void);
  157. int GifLastError(void);
  158.  
  159. /******************************************************************************
  160. * O.k. here are the routines from GIF_LIB file DEV2GIF.C.              *
  161. ******************************************************************************/
  162. int DumpScreen2Gif(char *FileName, int ReqGraphDriver, int ReqGraphMode1,
  163.                                int ReqGraphMode2,
  164.                                int ReqGraphMode3);
  165.  
  166. #endif /* GIF_LIB_H */
  167.