/* gif.h */ /****************************************************************************\ ** Title: GIF.H ** ** Purpose: GIF Header file ** ** Version: 1.0 ** ** Date: March 1992 ** ** Author: James D. Murray, Anaheim, CA, USA ** ** C Compilers: Borland C++ v2.0, Microsoft C v6.00a ** ** ** ** This file contains the header structures for the GIF image ** ** file format. ** ** ** ** ** ** Copyright (C) 1991 by Graphics Software Labs. All rights reserved. ** \****************************************************************************/ #ifndef GIF_H #define GIF_H 1 #include #include #include /* #include JSS */ /* #include "datatype.h" Data type definitions, physically here */ typedef unsigned char BYTE; typedef signed char SHORT; typedef short int WORD; typedef int DWORD; #undef VOID #define VOID void /* ** The GIF Global Color Table. ** ** The size of a color table may be any power of two from 2 to 256. ** We specify the maximum size here for clarity. */ typedef struct _GifGlobalColorTable { BYTE Red; /* Red Global Color Table Data */ BYTE Green; /* Green Global Color Table Data */ BYTE Blue; /* Blue Global Color Table Data */ } GIFGLOBALCT[256]; /* ** The GIF Local Color Table. ** ** The size of a color table may be any power of two from 2 to 256. ** We specify the maximum size here for clarity. */ typedef struct _GifLocalColorTable { BYTE Red; /* Red Global Color Table Data */ BYTE Green; /* Green Global Color Table Data */ BYTE Blue; /* Blue Global Color Table Data */ } GIFLOCALCT[256]; /* ** The GIF header format. ** ** This structure actually contains the header, logical screen ** descriptor, and the global color table for the GIF image. */ typedef struct _GifHeader /* Offset Description */ { BYTE Signature[3]; /* 00h ID Signature */ BYTE Version[3]; /* 03h Version Number */ WORD ScreenWidth; /* 06h Logical Screen Width */ WORD ScreenHeight; /* 08h Logical Screen Height */ BYTE PackedField; /* 0Ah Color Information */ BYTE ColorIndex; /* 0Bh Background Color Index */ BYTE AspectRatio; /* 0Ch Pixel Aspect Ratio */ GIFGLOBALCT GlobalCT; /* 0Dh Global Color Table */ } GIFHEAD; /* ** The GIF Image Descriptor. */ typedef struct _GifImageDescriptor { BYTE ImageSeparator; /* Image Descriptor identifier */ WORD ImageLeft; /* X position of image on the display */ WORD ImageTop; /* Y position of image on the display */ WORD ImageWidth; /* Width of the image in pixels */ WORD ImageHeight; /* Height of the image in pixels */ BYTE PackedField; /* Image and Color Table Data Information*/ GIFLOCALCT LocalCT; /* Local Color Table */ } GIFIMAGEDESC; /* ** GIF 89a Graphic Control Extension Block */ typedef struct _GifGraphicControlExtension { BYTE Introducer; /* Extension Introducer (always 21h) */ BYTE Label; /* Extension Label (always F9h) */ BYTE BlockSize; /* Size of Extension Block (always 04h) */ BYTE PackedField; /* Graphic Data Information */ WORD DelayTime; /* Delay time in hundredths of a second */ BYTE ColorIndex; /* Transparent Color Index */ BYTE Terminator; /* Block Terminator (always 0) */ } GIFGRAPHICCONTROL; /* ** GIF 89a Plain Text Extension Block */ typedef struct _GifPlainTextExtension { BYTE Introducer; /* Extension Introducer (always 21h) */ BYTE Label; /* Extension Label (always 01h) */ BYTE BlockSize; /* Size of Extension Block (always 0Ch) */ WORD TextGridLeft; /* X position of text grid in pixels */ WORD TextGridTop; /* Y position of text grid in pixels */ WORD TextGridWidth; /* Width of the text grid in pixels */ WORD TextGridHeight; /* Height of the text grid in pixels */ BYTE CellWidth; /* Width of a grid cell in pixels */ BYTE CellHeight; /* Height of a grid cell in pixels */ BYTE TextFgColorIndex; /* Text foreground color index value */ BYTE TextBgColorIndex; /* Text background color index value */ BYTE *PlainTextData; /* Plain Text data sub-blocks */ BYTE Terminator; /* Block Terminator (always 0) */ } GIFPLAINTEXT; /* ** GIF 89a Application Extension Block */ typedef struct _GifApplicationExtension { BYTE Introducer; /* Extension Introducer (always 21h) */ BYTE Label; /* Extension Label (always FFh) */ BYTE BlockSize; /* Size of Extension Block (always 0Bh) */ BYTE Identifier[8]; /* Application Identifier */ BYTE AuthentCode[3]; /* Application Authentication Code */ BYTE *ApplicationData; /* Application data sub-blocks */ BYTE Terminator; /* Block Terminator (always 0) */ } GIFAPPLICATION; /* ** GIF 89a Comment Extension Block */ typedef struct _GifCommentExtension { BYTE Introducer; /* Extension Introducer (always 21h) */ BYTE Label; /* Comment Label (always FEh) */ BYTE *CommentData; /* Comment data sub-blocks */ BYTE Terminator; /* Block Terminator (always 0) */ } GIFCOMMENT; /* ** Function Prototypes */ /* GIFREAD.C */ int ReadGifHeader(GIFHEAD *GifHead, FILE *FpGif); int ReadGifImageDesc(GIFIMAGEDESC *GifImageDesc, FILE *FpGif); int ReadGifGraphicControl(GIFGRAPHICCONTROL *GifGC, FILE *FpGif); int ReadGifPlainText(GIFPLAINTEXT *GifPlainText, FILE *FpGif); int ReadGifApplication(GIFAPPLICATION *GifApplication, FILE *FpGif); int ReadGifComment(GIFCOMMENT *GifComment, FILE *FpGif); WORD GetWord(FILE *FpGif); /* little endian */ BYTE GetByte(FILE *FpGif); DWORD GetDword(FILE *FpGif); VOID GetString(char * str, int len, FILE *FpGif); VOID PutWord(WORD x, FILE *FpGif); VOID PutByte(BYTE x, FILE *FpGif); VOID PutDword(DWORD x, FILE *FpGif); VOID PutString(char * str, int len, FILE *FpGif); #endif /* GIF_H */