//	GifMaker.h//	This is the header file for the GifMaker class.//	By Joe Strout	1/27/96//	Hearty thanks to:     Sverre H. Huseby//                            Bjoelsengt. 17//                            N-0468 Oslo//                            Norway      //                            sverrehu@ifi.uio.no#ifndef GIFMAKER_H#define GIFMAKER_H#ifdef macintosh#include <Types.h>#endif#include "Color.h"#include <stdio.h>typedef unsigned Word;          /* At least two bytes (16 bits) */typedef unsigned char Byte;     /* Exactly one byte (8 bits) */typedef struct {    Word LocalScreenWidth,         LocalScreenHeight;    Byte GlobalColorTableSize : 3,         SortFlag             : 1,         ColorResolution      : 3,         GlobalColorTableFlag : 1;    Byte BackgroundColorIndex;    Byte PixelAspectRatio;} ScreenDescriptor;typedef struct {    Byte Separator;    Word LeftPosition,         TopPosition;    Word Width,         Height;    Byte LocalColorTableSize : 3,         Reserved            : 2,         SortFlag            : 1,         InterlaceFlag       : 1,         LocalColorTableFlag : 1;} ImageDescriptor;class GifMaker{public:	GifMaker();			// constructor -- sets default values	int SaveGif( const char *pFilename );		// make the GIF file; return 1 if good	// functions which must be overridden to make a picture:		virtual RGB GetColor( const int pColorNum )			// get color palette entry	{ return RGB(0,0,0); }	virtual int GetPixel( const int pX, const int pY )		// get color number at a location	{ return 0; }		// public variables:	int itsWidth;	int itsHeight;	int itsQtyColors;	int itsColorBits;	#ifdef macintosh		OSType itsFileCreator;	#endif		// private parts:protected:	enum GIF_Code {	    GIF_OK,	    GIF_ERRCREATE,	    GIF_ERRWRITE,	    GIF_OUTMEM	};	FILE *OutFile;           /* File to write to */	Byte Buffer[256];        /* There must be one too much !!! */	int  Index,              /* Current byte in buffer */         BitsLeft;           /* Bits left to fill in current byte. These                                   are right-justified */	Byte *StrChr;	Word *StrNxt,            *StrHsh,            NumStrings;	int  BitsPrPrimColor,    /* Bits pr primary color */            NumColors;          /* Number of colors in color table */	Byte *ColorTable;	Word ScreenHeight,            ScreenWidth,            ImageHeight,            ImageWidth,            ImageLeft,            ImageTop,            RelPixX, RelPixY;         /* Used by InputByte() -function */	int Create(const char *filename);	int Write(void *buf, unsigned len);	int WriteByte(Byte b);	int WriteWord(Word w);	void Close(void);	void InitBitFile(void);	int ResetOutBitFile(void);	int WriteBits(int bits, int numbits);	void FreeStrtab(void);	int AllocStrtab(void);	Word AddCharString(Word index, Byte b);	Word FindCharString(Word index, Byte b);	void ClearStrtab(int codesize);	int LZW_Compress(int codesize );	int BitsNeeded(Word n);	int InputByte(void);	int WriteScreenDescriptor(ScreenDescriptor *sd);	int WriteImageDescriptor(ImageDescriptor *id);	int GIF_Create(const char *filename, int width, int height, int numcolors, int colorres);	void GIF_SetColor(int colornum, int red, int green, int blue);	int GIF_CompressImage(int left, int top, int width, int height );	int GIF_Close(void);};#endif
