home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / graphics / gifbla20.zip / SOURCE / GIFCODE.H < prev    next >
C/C++ Source or Header  |  1992-12-15  |  2KB  |  64 lines

  1.  
  2. /* gifcode.h - Include file for GIF encoder/decoder routines. */
  3.  
  4. #ifndef P_DEFINED
  5. #define P_DEFINED
  6. #ifdef NOPROTOS
  7. #define P(a,b) b
  8. #else
  9. #define P(a,b) a
  10. #endif
  11. #endif
  12.  
  13. #define GIF_MAXCODES 4096
  14. typedef struct {
  15.     FFILE *ff;
  16.     unsigned char curblock[256];
  17.     int curblocksize,curblockpos;
  18.     int nbits;
  19.     long bits;
  20.     int datasize;
  21.     int clear,eoi;
  22.     int prefix[GIF_MAXCODES];
  23.     unsigned char suffix[GIF_MAXCODES];
  24.     int codesize,codemask;
  25.     int avail;
  26.     union {
  27.         struct {
  28.             int sl_ptr[GIF_MAXCODES];
  29.             int sl_index;
  30.             unsigned char sl_suffix[GIF_MAXCODES];
  31.             int sl_newprefix[GIF_MAXCODES];
  32.             int sl_next[GIF_MAXCODES];
  33.             int curprefix;
  34.         } e;
  35.         struct {
  36.             int prevc;
  37.             unsigned char first[GIF_MAXCODES];
  38.             unsigned char cstack[GIF_MAXCODES];
  39.             int csttop;
  40.         } d;
  41.     } u;
  42. } GIF_CODER;
  43.  
  44. /* functions/macros used internally only: */
  45. extern int gif___f_decode_c P((GIF_CODER *gc),());
  46.  
  47. /* functions/macros for external use: */
  48. extern void gif_start_encoding P((GIF_CODER *gc, FFILE *ff, int datasize),());
  49. /* Prepares to encode an image to ff. Normally datasize will be the bits per
  50.     pixel for the image, except for binary images where datasize = 2. */
  51. extern int gif_encode_c P((int c, GIF_CODER *gc),());
  52. /* Encodes a single pixel. Returns 0 on success, or -1 on failure. */
  53. extern int gif_end_encoding P((GIF_CODER *gc),());
  54. /* Ends encoding. Returns 0 on success, or -1 on failure. */
  55. extern void gif_start_decoding P((GIF_CODER *gc, FFILE *ff, int datasize),());
  56. /* Prepares to decode an image from ff. Normally datasize will be the bits per
  57.     pixel for the image, except for binary images where datasize = 2. */
  58. #define gif_decode_c(gc) ((gc)->u.d.csttop>0 \
  59.     ? (gc)->u.d.cstack[--((gc)->u.d.csttop)] : gif___f_decode_c(gc))
  60. /* Decodes a single pixel. Returns a pixel value on success, or -1
  61.     on failure. */
  62. int gif_end_decoding P((GIF_CODER *gc),());
  63. /* Ends decoding. Returns 0 on success, or -1 on failure. */
  64.