/* Copyright 1990 by Christopher A. Wichura. See file GIFMachine.doc for full description of rights. */ #include #include #include #include #include #include #include /* some structures to make parsing the gif files a bit easier */ struct GIFdescriptor { UWORD gd_Width; UWORD gd_Height; UBYTE gd_ColInfo; UBYTE gd_BackGround; UBYTE gd_PixelAspect; /* Aspect Ratio = (Pixel Aspect + 15) / 64 */ }; struct ImageDesc { UWORD id_Left; UWORD id_Top; UWORD id_Width; UWORD id_Height; UBYTE id_Info; }; struct RGB { UBYTE rgb_Red; UBYTE rgb_Green; UBYTE rgb_Blue; }; #define GIF_IMAGE 0x2C #define GIF_EXTENSION 0x21 #define GIF_TERMINATOR 0x3B #define GIF_COMMENT_EXT 0xFE #define MAXCOLOURS 4096 /* these next macros are used to get the r, g, and b values of a given index */ #define GetRed(a) (UBYTE)(a >> 8) #define GetGreen(a) (UBYTE)((a >> 4) & 0xF) #define GetBlue(a) (UBYTE)(a & 0xF) /* whenever we want to abort we will return this as our error code */ #define ABORTEXITVAL 1 /* this struct is used to hold the linked list of comments found in the GIF file so that each can be written as a seperate ANNO chunk. */ struct CommentNode { struct MinNode cn_Node; char *cn_Comment; ULONG cn_CommentLength; }; /* function prototypes we use */ extern int __regargs main(char *cmdptr, int cmdlen, struct WBStartup *WBMsg); extern void WarnMustUseCLI(void); extern void DoPattern(char *); extern void Convert(char *); extern BOOL IsDir(char *); extern void FlipWord(UWORD *); extern BOOL DoImage(BPTR); extern BOOL DoExtension(BPTR); extern BOOL WriteIFF(char *, BOOL); extern void PutValue(UWORD, UWORD, UWORD); extern UWORD GetValue(UWORD, UWORD); extern int ReadCode(BPTR); extern void AddPixel(UBYTE); extern void StripBorder(void); extern BOOL BorderCheck(UWORD, UWORD); extern void DoXComp(void); extern void GIFtoSHAM(void); extern void InitDiff(void); extern ULONG RGBdiff(UBYTE, UBYTE, UBYTE, UBYTE, UBYTE, UBYTE); extern void OutDump(int); extern void OutRun(int, int); extern void InitMemory(void); extern char * MyAlloc(ULONG); extern void MyFree(char *); extern void FreeAll(UWORD); extern void MyExit(ULONG); extern void DoXFlip(void); extern void DoYFlip(void); extern void ReduceTo12(void); extern void DitherTo12(void); extern UWORD AddColour(struct RGB *); extern void __stdargs MyPrintf(char *, ...); extern void __stdargs MySPrintf(char *, char *, ...); /* modules that want to use the Get/PutValue macros should include this next macro to externally reference the picture storage array */ #define EXTERNBITPLANE extern struct RGB **BitPlane /* for use once colour palette has been reduced to 12 bits */ #define GetValue(a, b) *((UWORD *)&BitPlane[b][a]) #define PutValue(a, b, c) *((UWORD *)&BitPlane[b][a]) = c