diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-02-28 15:32:49 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-02-28 15:32:49 (GMT) |
commit | efcdbf2e38169cb7b8a0c435defaafaecb16b6a4 (patch) | |
tree | a46c022c6047ef59eb503af32834de32b7667dc4 /hl/tools | |
parent | 467b5d565cc6bb0a75f10ac0807c38ee0a0939a9 (diff) | |
download | hdf5-efcdbf2e38169cb7b8a0c435defaafaecb16b6a4.zip hdf5-efcdbf2e38169cb7b8a0c435defaafaecb16b6a4.tar.gz hdf5-efcdbf2e38169cb7b8a0c435defaafaecb16b6a4.tar.bz2 |
Fix gif2h5 tool build on windows
Diffstat (limited to 'hl/tools')
-rw-r--r-- | hl/tools/gif2h5/decompress.c | 50 | ||||
-rw-r--r-- | hl/tools/gif2h5/gif.h | 131 | ||||
-rw-r--r-- | hl/tools/gif2h5/gif2hdf.c | 6 | ||||
-rw-r--r-- | hl/tools/gif2h5/gif2mem.c | 46 | ||||
-rw-r--r-- | hl/tools/gif2h5/gifread.c | 92 | ||||
-rw-r--r-- | hl/tools/gif2h5/hdf2gif.c | 34 | ||||
-rw-r--r-- | hl/tools/gif2h5/hdfgifwr.c | 2 | ||||
-rw-r--r-- | hl/tools/gif2h5/writehdf.c | 6 |
8 files changed, 187 insertions, 180 deletions
diff --git a/hl/tools/gif2h5/decompress.c b/hl/tools/gif2h5/decompress.c index bd9a37d..8cd8a8e 100644 --- a/hl/tools/gif2h5/decompress.c +++ b/hl/tools/gif2h5/decompress.c @@ -15,13 +15,13 @@ #include "gif.h" -WORD iWIDE, iHIGH, eWIDE, eHIGH, expand, numcols, strip, nostrip; +GIFWORD iWIDE, iHIGH, eWIDE, eHIGH, expand, numcols, strip, nostrip; unsigned long cols[256]; char *cmd; FILE *fp; -static WORD +static GIFWORD XC = 0, YC = 0, /* Output X and Y coords of current pixel */ InitCodeSize, /* Starting code size, used during Clear */ CodeSize, /* Code size, read from GIF header */ @@ -29,7 +29,7 @@ static WORD IWidth, IHeight; /* image dimensions */ static int BitOffset = 0, /* Bit Offset of next code */ - Pass = 0, /* Used by output routine if WORDerlaced pic */ + Pass = 0, /* Used by output routine if GIFWORDerlaced pic */ OutCount = 0, /* Decompressor output 'stack count' */ Code, /* Value returned by ReadCode */ MaxCode, /* limiting value for current code size */ @@ -43,17 +43,17 @@ static int ReadMask; /* Code AND mask for current code size */ /*MODIFICATIONS*/ -BYTE tempbyte[10]; -BYTE * tempBYTEptr[10]; -WORD tempint[10]; -WORD ImageCount = 0; +GIFBYTE tempbyte[10]; +GIFBYTE * tempGIFBYTEptr[10]; +GIFWORD tempint[10]; +GIFWORD ImageCount = 0; /*END MODIFICATION*/ boolean Interlace, HasColormap; -BYTE *Image; /* The result array */ -BYTE *RawGIF; /* The heap array to hold it, raw */ -BYTE *Raster; /* The raster data stream, unblocked */ +GIFBYTE *Image; /* The result array */ +GIFBYTE *RawGIF; /* The heap array to hold it, raw */ +GIFBYTE *Raster; /* The raster data stream, unblocked */ /* The hash table used by the decompressor */ @@ -70,10 +70,10 @@ int numused; /* * Fetch the next code from the raster data stream. The codes can be any - * length from 3 to 12 bits, packed WORDo 8-bit BYTEs, so we have to maWORDain - * our location in the Raster array as a BIT Offset. We compute the BYTE - * Offset WORDo the raster array by dividing this by 8, pick up three BYTEs, - * compute the bit Offset WORDo our 24-bit chunk, shift to bring the desired + * length from 3 to 12 bits, packed into 8-bit GIFBYTEs, so we have to maintain + * our location in the Raster array as a BIT Offset. We compute the GIFBYTE + * Offset into the raster array by dividing this by 8, pick up three GIFBYTEs, + * compute the bit Offset into our 24-bit chunk, shift to bring the desired * code to the bottom, then mask it off and return it. */ static int @@ -93,7 +93,7 @@ ReadCode(void) } static void -AddToPixel(BYTE Index) +AddToPixel(GIFBYTE Index) { if (YC<IHeight) *(Image + YC * BytesPerScanline + XC) = Index; @@ -104,8 +104,8 @@ AddToPixel(BYTE Index) * Y-coordinate */ if (++XC == IWidth) { /* - * If a non-WORDerlaced picture, just increment YC to the next scan - * line. If it's WORDerlaced, deal with the WORDerlace as described + * If a non-interlaced picture, just increment YC to the next scan + * line. If it's interlaced, deal with the interlace as described * in the GIF spec. Put the decoded scan line out to the screen if we * haven't gone past the bottom of it. */ @@ -154,7 +154,7 @@ AddToPixel(BYTE Index) /* Main routine. Convert a GIF image to an HDF image */ -BYTE * +GIFBYTE * Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) { int i; @@ -183,7 +183,7 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) */ /* - * Start reading the raster data. First we get the WORDial code size and + * Start reading the raster data. First we get the intial code size and * compute decompressor constant values, based on this code size. */ @@ -206,13 +206,13 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) /* * Read the raster data. Here we just transpose it from the GIF array to - * the Raster array, turning it from a series of blocks WORDo one long + * the Raster array, turning it from a series of blocks into one long * data stream, which makes life much easier for ReadCode(). */ /* Allocate the Image */ - if (!(Image = (BYTE *)malloc((size_t)IWidth*(size_t)IHeight))) { + if (!(Image = (GIFBYTE *)malloc((size_t)IWidth*(size_t)IHeight))) { printf("Out of memory"); exit(EXIT_FAILURE); } @@ -238,7 +238,7 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) FreeCode = FirstFree; CurCode = OldCode = Code = ReadCode(); FinChar = CurCode & DataMask; - AddToPixel((BYTE)FinChar); + AddToPixel((GIFBYTE)FinChar); } else { /* * If not a clear code, then must be data: save same as CurCode @@ -256,7 +256,7 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) } /* - * Unless this code is raw data, pursue the chain poWORDed to by + * Unless this code is raw data, pursue the chain pointed to by * CurCode through the hash table to its end; each code in the * chain puts its associated output code on the output queue. */ @@ -278,7 +278,7 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) * stacked LIFO, so deal with it that way... */ for (i = OutCount - 1; i >= 0; i--) - AddToPixel((BYTE)OutCode[i]); + AddToPixel((GIFBYTE)OutCode[i]); OutCount = 0; @@ -291,7 +291,7 @@ Decompress(GIFIMAGEDESC *GifImageDesc, GIFHEAD *GifHead) OldCode = InCode; /* - * PoWORD to the next slot in the table. If we exceed the current + * Point to the next slot in the table. If we exceed the current * MaxCode value, increment the code size unless it's already 12. * If it is, do nothing: the next code decompressed better be * CLEAR diff --git a/hl/tools/gif2h5/gif.h b/hl/tools/gif2h5/gif.h index ed1cc81..0c0f963 100644 --- a/hl/tools/gif2h5/gif.h +++ b/hl/tools/gif2h5/gif.h @@ -26,17 +26,24 @@ #define MAX_PAL 768 -/* typedef H5T_NATIVE_UINT8 BYTE; */ -typedef unsigned char BYTE; +/* typedef H5T_NATIVE_UINT8 GIFBYTE; */ +typedef unsigned char GIFBYTE; -/* typedef H5T_NATIVE_UINT16 WORD; */ -typedef unsigned long WORD; +/* typedef H5T_NATIVE_UINT16 GIFWORD; */ +typedef unsigned long GIFWORD; -typedef char CHAR; +typedef char GIFCHAR; + +#ifndef boolean typedef unsigned char boolean; +#endif +#ifndef false #define false 0 +#endif +#ifndef true #define true 1 +#endif /* Set the EndianOrder. ** The GIF Reader file should do this. @@ -52,15 +59,15 @@ extern int EndianOrder; ** descriptor, and the global color table for the GIF image. */ typedef struct _GifHeader { /* Offset Description */ - BYTE PackedField; /* 0Ah Color Information */ - WORD TableSize; - BYTE ImageCount; /* Keep a count of the number of images */ - BYTE CommentCount; - BYTE ApplicationCount; - BYTE PlainTextCount; - BYTE HDFPalette[256][3]; - BYTE HeaderDump[6]; /* BYTE array to dump header contents */ - BYTE LSDDump[7]; /* Logical Screen Descriptor dump */ + GIFBYTE PackedField; /* 0Ah Color Information */ + GIFWORD TableSize; + GIFBYTE ImageCount; /* Keep a count of the number of images */ + GIFBYTE CommentCount; + GIFBYTE ApplicationCount; + GIFBYTE PlainTextCount; + GIFBYTE HDFPalette[256][3]; + GIFBYTE HeaderDump[6]; /* GIFBYTE array to dump header contents */ + GIFBYTE LSDDump[7]; /* Logical Screen Descriptor dump */ } GIFHEAD; @@ -68,32 +75,32 @@ typedef struct _GifHeader { /* Offset Description */ ** The GIF Image Descriptor. */ typedef struct _GifImageDescriptor { - WORD ImageWidth; /* Width of the image in pixels */ - WORD ImageHeight; /* Height of the image in pixels */ - BYTE PackedField; /* Image and Color Table Data Information */ - WORD TableSize; - WORD CodeSize; /* Minimum LZW CodeSize for image data */ - BYTE HDFPalette[256][3]; - BYTE GIDDump[9]; /* GifImageDescriptor dump */ - - BYTE *Image; /* Decompressed Raster Image */ - BYTE *GIFImage; + GIFWORD ImageWidth; /* Width of the image in pixels */ + GIFWORD ImageHeight; /* Height of the image in pixels */ + GIFBYTE PackedField; /* Image and Color Table Data Information */ + GIFWORD TableSize; + GIFWORD CodeSize; /* Minimum LZW CodeSize for image data */ + GIFBYTE HDFPalette[256][3]; + GIFBYTE GIDDump[9]; /* GifImageDescriptor dump */ + + GIFBYTE *Image; /* Decompressed Raster Image */ + GIFBYTE *GIFImage; } GIFIMAGEDESC; /* ** GIF 89a Graphic Control Extension Block */ typedef struct _GifGraphicControlExtension { - BYTE GCEDump[5]; /* Graphic Control Extension Dump */ + GIFBYTE GCEDump[5]; /* Graphic Control Extension Dump */ } GIFGRAPHICCONTROL; /* ** GIF 89a Plain Text Extension Block */ typedef struct _GifPlainTextExtension { - BYTE PTEDump[15]; /* Plain Text Extension Dump */ - BYTE *PlainTextData; /* Plain Text data sub-blocks */ - WORD DataSize; + GIFBYTE PTEDump[15]; /* Plain Text Extension Dump */ + GIFBYTE *PlainTextData; /* Plain Text data sub-blocks */ + GIFWORD DataSize; } GIFPLAINTEXT; @@ -101,19 +108,19 @@ typedef struct _GifPlainTextExtension { ** GIF 89a Application Extension Block */ typedef struct _GifApplicationExtension { - BYTE AEDump[14]; /* Application Extension Dump */ - BYTE *ApplicationData; /* Application data sub-blocks */ - WORD DataSize; + GIFBYTE AEDump[14]; /* Application Extension Dump */ + GIFBYTE *ApplicationData; /* Application data sub-blocks */ + GIFWORD DataSize; } GIFAPPLICATION; /* ** GIF 89a Comment Extension Block */ typedef struct _GifCommentExtension { - BYTE CEDump[2]; /* Comment Extension Dump */ - BYTE *CommentData; /* Comment data sub-blocks */ - WORD DataSize; - BYTE Terminator; /* Block Terminator (always 0) */ + GIFBYTE CEDump[2]; /* Comment Extension Dump */ + GIFBYTE *CommentData; /* Comment data sub-blocks */ + GIFWORD DataSize; + GIFBYTE Terminator; /* Block Terminator (always 0) */ } GIFCOMMENT; /* @@ -128,12 +135,12 @@ typedef struct _GifCommentExtension { ** extension. */ typedef struct _GifToMem { - GIFHEAD *GifHeader; - GIFIMAGEDESC **GifImageDesc; - GIFGRAPHICCONTROL **GifGraphicControlExtension; - GIFPLAINTEXT **GifPlainTextExtension; - GIFAPPLICATION **GifApplicationExtension; - GIFCOMMENT **GifCommentExtension; + GIFHEAD *GifHeader; + GIFIMAGEDESC **GifImageDesc; + GIFGRAPHICCONTROL **GifGraphicControlExtension; + GIFPLAINTEXT **GifPlainTextExtension; + GIFAPPLICATION **GifApplicationExtension; + GIFCOMMENT **GifCommentExtension; } GIFTOMEM; /* @@ -141,40 +148,40 @@ typedef struct _GifToMem { */ /* GIF2MEM.C */ -int Gif2Mem(BYTE *, GIFTOMEM *); +int Gif2Mem(GIFBYTE *, GIFTOMEM *); /* GIFREAD.C */ -int ReadGifHeader(GIFHEAD *, BYTE **); -int ReadGifImageDesc(GIFIMAGEDESC *, BYTE **); -int ReadGifGraphicControl(GIFGRAPHICCONTROL *, BYTE **); -int ReadGifPlainText(GIFPLAINTEXT *, BYTE **); -int ReadGifApplication(GIFAPPLICATION *, BYTE **); -int ReadGifComment(GIFCOMMENT *, BYTE **); +int ReadGifHeader(GIFHEAD *, GIFBYTE **); +int ReadGifImageDesc(GIFIMAGEDESC *, GIFBYTE **); +int ReadGifGraphicControl(GIFGRAPHICCONTROL *, GIFBYTE **); +int ReadGifPlainText(GIFPLAINTEXT *, GIFBYTE **); +int ReadGifApplication(GIFAPPLICATION *, GIFBYTE **); +int ReadGifComment(GIFCOMMENT *, GIFBYTE **); /* HDFGIFWR.C */ -int hdfWriteGIF(FILE *fp, BYTE *pic, int ptype, int w, int h, BYTE *rmap, - BYTE *gmap, BYTE *bmap, BYTE *pc2ncmap, int numcols, +int hdfWriteGIF(FILE *fp, GIFBYTE *pic, int ptype, int w, int h, GIFBYTE *rmap, + GIFBYTE *gmap, GIFBYTE *bmap, GIFBYTE *pc2ncmap, int numcols, int colorstyle, int BitsPerPixel); /* WRITEHDF.C */ -int WriteHDF(GIFTOMEM , CHAR * ); +int WriteHDF(GIFTOMEM , GIFCHAR * ); /* Function: ReadHDF ** Return: 0 on completion without error, -1 on error -** Input: CHAR *h5_file - HDF file name -** CHAR *dset_name - Name of the HDF Image dataset -** CHAR *pal_name - Name of the HDF palette -** Output: BYTE* data - the HDF Image to be converted -** BYTE palette[256][3] - the corresponding palette +** Input: GIFCHAR *h5_file - HDF file name +** GIFCHAR *dset_name - Name of the HDF Image dataset +** GIFCHAR *pal_name - Name of the HDF palette +** Output: GIFBYTE* data - the HDF Image to be converted +** GIFBYTE palette[256][3] - the corresponding palette ** hsize_t* image_size - the size of each dimension of the image */ -int ReadHDF(BYTE** data, BYTE palette[256][3], hsize_t *image_size, - CHAR *h5_file, CHAR *dset_name, CHAR *pal_name); +int ReadHDF(GIFBYTE** data, GIFBYTE palette[256][3], hsize_t *image_size, + GIFCHAR *h5_file, GIFCHAR *dset_name, GIFCHAR *pal_name); -BYTE *Decompress(GIFIMAGEDESC *, GIFHEAD *); -BYTE GetByte(BYTE *); -WORD GetWord(BYTE *); +GIFBYTE *Decompress(GIFIMAGEDESC *, GIFHEAD *); +GIFBYTE GetByte(GIFBYTE *); +GIFWORD GetWord(GIFBYTE *); -void cleanup(BYTE*); +void cleanup(GIFBYTE*); #endif /* GIF_H_ */ diff --git a/hl/tools/gif2h5/gif2hdf.c b/hl/tools/gif2h5/gif2hdf.c index 2e06d34..051ff56 100644 --- a/hl/tools/gif2h5/gif2hdf.c +++ b/hl/tools/gif2h5/gif2hdf.c @@ -31,8 +31,8 @@ main(int argv , char *argc[]) long i, ImageCount; long filesize; - BYTE *MemGif; - BYTE *StartPos; + GIFBYTE *MemGif; + GIFBYTE *StartPos; char *GIFFileName; char *HDFFileName; @@ -81,7 +81,7 @@ main(int argv , char *argc[]) if (filesize == 0) printf("File Size Zero"); - if (!(MemGif = StartPos = (BYTE *)malloc((size_t)filesize))) { + if (!(MemGif = StartPos = (GIFBYTE *)malloc((size_t)filesize))) { printf("Out of memory"); exit(EXIT_FAILURE); } diff --git a/hl/tools/gif2h5/gif2mem.c b/hl/tools/gif2h5/gif2mem.c index 8fb575c..ae0a113 100644 --- a/hl/tools/gif2h5/gif2mem.c +++ b/hl/tools/gif2h5/gif2mem.c @@ -36,7 +36,7 @@ #include "gif.h" int -Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct) +Gif2Mem(GIFBYTE *MemGif, GIFTOMEM *GifMemoryStruct) { /* * The gif structure outline for passing data to memory is given in gif.h. @@ -49,22 +49,22 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct) GIFCOMMENT **gifComment; /* Comment Extension structure */ GIFGRAPHICCONTROL **gifGraphicControl; /* Graphic Control Extension strct */ - register WORD i; /* Loop counter */ - BYTE Identifier; /* Extension block identifier holder */ - BYTE Label; /* Extension block label holder */ - BYTE ImageCount; /* Count of the number of images in the file */ - BYTE ImageArray; /* Keep the size of the array to store Images */ - BYTE CommentCount; - BYTE CommentArray; - BYTE ApplicationCount; - BYTE ApplicationArray; - BYTE PlainTextCount; - BYTE PlainTextArray; - BYTE GCEflag; - BYTE aTemp; - BYTE j; - BYTE w; /* Two more variables needed only while testing */ - BYTE *b; /* Endian Ordering */ + register GIFWORD i; /* Loop counter */ + GIFBYTE Identifier; /* Extension block identifier holder */ + GIFBYTE Label; /* Extension block label holder */ + GIFBYTE ImageCount; /* Count of the number of images in the file */ + GIFBYTE ImageArray; /* Keep the size of the array to store Images */ + GIFBYTE CommentCount; + GIFBYTE CommentArray; + GIFBYTE ApplicationCount; + GIFBYTE ApplicationArray; + GIFBYTE PlainTextCount; + GIFBYTE PlainTextArray; + GIFBYTE GCEflag; + GIFBYTE aTemp; + GIFBYTE j; + GIFBYTE w; /* Two more variables needed only while testing */ + GIFBYTE *b; /* Endian Ordering */ /* Allocate memory for the GIF structures */ /* Plug the structs into GifMemoryStruct at the end */ @@ -90,7 +90,7 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct) /* Carry out Endian Testing and set Endian Order */ w = 0x0001; - b = (BYTE *) &w; + b = (GIFBYTE *) &w; EndianOrder = (b[0] ? 1 : 0); /* Read the GIF image file header information */ @@ -151,7 +151,7 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct) if (ImageCount > ImageArray) { aTemp = ImageArray; - ImageArray = (BYTE)((ImageArray << 1) + 1); + ImageArray = (GIFBYTE)((ImageArray << 1) + 1); if (!(gifImageDesc = (GIFIMAGEDESC **)realloc(gifImageDesc, sizeof(GIFIMAGEDESC *) * ImageArray))) { printf("Out of memory!"); @@ -218,7 +218,7 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct) PlainTextCount++; if (PlainTextCount > PlainTextArray) - PlainTextArray = (BYTE)((PlainTextArray << 1) + 1); + PlainTextArray = (GIFBYTE)((PlainTextArray << 1) + 1); if (!(gifPlainText = (GIFPLAINTEXT **)realloc(gifPlainText , sizeof(GIFPLAINTEXT *) * PlainTextArray))) { printf("Out of memory!"); @@ -240,7 +240,7 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct) CommentCount++; if (CommentCount > CommentArray) - CommentArray = (BYTE)((CommentArray << 1) + 1); + CommentArray = (GIFBYTE)((CommentArray << 1) + 1); if (!(gifComment = (GIFCOMMENT **)realloc(gifComment , sizeof(GIFCOMMENT *) * CommentArray))) { printf("Out of memory!"); @@ -267,7 +267,7 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct) if (ImageCount > ImageArray) { aTemp = ImageArray; - ImageArray = (BYTE)((ImageArray << 1) + 1); + ImageArray = (GIFBYTE)((ImageArray << 1) + 1); if (!(gifGraphicControl = (GIFGRAPHICCONTROL **)realloc(gifGraphicControl , sizeof(GIFGRAPHICCONTROL *) * ImageArray))) { printf("Out of memory!"); @@ -306,7 +306,7 @@ Gif2Mem(BYTE *MemGif, GIFTOMEM *GifMemoryStruct) ApplicationCount++; if (ApplicationCount > ApplicationArray) - ApplicationArray = (BYTE)((ApplicationArray << 1) + 1); + ApplicationArray = (GIFBYTE)((ApplicationArray << 1) + 1); if (!(gifApplication = (GIFAPPLICATION **)realloc(gifApplication , sizeof(GIFAPPLICATION *) * ApplicationArray))) { printf("Out of memory!"); diff --git a/hl/tools/gif2h5/gifread.c b/hl/tools/gif2h5/gifread.c index 948e112..79671aa 100644 --- a/hl/tools/gif2h5/gifread.c +++ b/hl/tools/gif2h5/gifread.c @@ -17,33 +17,33 @@ int EndianOrder; -static BYTE *ReadDataSubBlocks(BYTE **MemGif2, WORD *DSize); +static GIFBYTE *ReadDataSubBlocks(GIFBYTE **MemGif2, GIFWORD *DSize); -WORD -GetWord(BYTE *MemGif) +GIFWORD +GetWord(GIFBYTE *MemGif) { - WORD w; + GIFWORD w; if (EndianOrder == 1) { /* LittleEndian */ - w = (WORD) (*MemGif++ & 0xFF); - w |= (WORD) ((*MemGif++ & 0xFF) << 0x08); + w = (GIFWORD) (*MemGif++ & 0xFF); + w |= (GIFWORD) ((*MemGif++ & 0xFF) << 0x08); } else { - w = (WORD) (*MemGif++ & 0xFF); - w = ((WORD) (*MemGif++ & 0xFF)) | (w << 0x08); + w = (GIFWORD) (*MemGif++ & 0xFF); + w = ((GIFWORD) (*MemGif++ & 0xFF)) | (w << 0x08); } return w; } -BYTE -GetByte(BYTE *MemGif) +GIFBYTE +GetByte(GIFBYTE *MemGif) { return *MemGif; } /* - * Read a GIF image BYTE Header. + * Read a GIF image GIFBYTE Header. * * This function reads the Header, Logical Screen Descriptor, and * Global Color Table (if any) from a GIF image file. The information @@ -54,10 +54,10 @@ GetByte(BYTE *MemGif) */ int ReadGifHeader(GIFHEAD *GifHead, /* Pointer to GIF header structure */ - BYTE **MemGif2) /* GIF image file input FILE stream */ + GIFBYTE **MemGif2) /* GIF image file input FILE stream */ { - WORD i; /* Loop counter */ - WORD tableSize; /* Number of entires in the Global Color Table */ + GIFWORD i; /* Loop counter */ + GIFWORD tableSize; /* Number of entires in the Global Color Table */ GifHead->TableSize = 0; for (i = 0 ; i < 6 ; i++) { @@ -78,7 +78,7 @@ ReadGifHeader(GIFHEAD *GifHead, /* Pointer to GIF header structure */ /* Check if a Global Color Table is present */ if (GifHead->PackedField & 0x80) { /* Read number of color table entries */ - tableSize = (WORD) (1L << ((GifHead->PackedField & 0x07) + 1)); + tableSize = (GIFWORD) (1L << ((GifHead->PackedField & 0x07) + 1)); GifHead->TableSize = tableSize; /* Read the Global Color Table */ @@ -122,13 +122,13 @@ ReadGifHeader(GIFHEAD *GifHead, /* Pointer to GIF header structure */ int ReadGifImageDesc( GIFIMAGEDESC *GifImageDesc, /* Pointer to GIF image descriptor structure */ - BYTE **MemGif2 /* GIF image file input FILE stream */ + GIFBYTE **MemGif2 /* GIF image file input FILE stream */ ) { - WORD i; /* Loop counter */ - WORD tableSize; /* Number of entries in the Local Color Table */ - /* BYTE Interlace; */ /* PackedField & 0x20 gives information on interlacing */ - BYTE *TempPtr; + GIFWORD i; /* Loop counter */ + GIFWORD tableSize; /* Number of entries in the Local Color Table */ + /* GIFBYTE Interlace; */ /* PackedField & 0x20 gives information on interlacing */ + GIFBYTE *TempPtr; int ch , ch1; GifImageDesc->TableSize = 0; @@ -145,20 +145,20 @@ ReadGifImageDesc( if (EndianOrder == 1) /* LittleEndian */ { - GifImageDesc->ImageWidth = (WORD) (GifImageDesc->GIDDump[4] & 0xFF); - GifImageDesc->ImageWidth |= (WORD) ((GifImageDesc->GIDDump[5] & 0xFF) << 0x08); + GifImageDesc->ImageWidth = (GIFWORD) (GifImageDesc->GIDDump[4] & 0xFF); + GifImageDesc->ImageWidth |= (GIFWORD) ((GifImageDesc->GIDDump[5] & 0xFF) << 0x08); - GifImageDesc->ImageHeight = (WORD) (GifImageDesc->GIDDump[6] & 0xFF); - GifImageDesc->ImageHeight |= (WORD) ((GifImageDesc->GIDDump[7] & 0xFF) << 0x08); + GifImageDesc->ImageHeight = (GIFWORD) (GifImageDesc->GIDDump[6] & 0xFF); + GifImageDesc->ImageHeight |= (GIFWORD) ((GifImageDesc->GIDDump[7] & 0xFF) << 0x08); } else { - GifImageDesc->ImageWidth = (WORD) (GifImageDesc->GIDDump[4] & 0xFF); - GifImageDesc->ImageWidth = ((WORD) (GifImageDesc->GIDDump[5] & 0xFF)) | (GifImageDesc->ImageWidth << 0x08); + GifImageDesc->ImageWidth = (GIFWORD) (GifImageDesc->GIDDump[4] & 0xFF); + GifImageDesc->ImageWidth = ((GIFWORD) (GifImageDesc->GIDDump[5] & 0xFF)) | (GifImageDesc->ImageWidth << 0x08); - GifImageDesc->ImageHeight = (WORD) (GifImageDesc->GIDDump[6] & 0xFF); - GifImageDesc->ImageHeight = ((WORD) (GifImageDesc->GIDDump[7] & 0xFF)) | (GifImageDesc->ImageWidth << 0x08); + GifImageDesc->ImageHeight = (GIFWORD) (GifImageDesc->GIDDump[6] & 0xFF); + GifImageDesc->ImageHeight = ((GIFWORD) (GifImageDesc->GIDDump[7] & 0xFF)) | (GifImageDesc->ImageWidth << 0x08); } @@ -171,7 +171,7 @@ ReadGifImageDesc( if (GifImageDesc->PackedField & 0x80) { /* Read number of color table entries */ - tableSize = (WORD) (1L << ((GifImageDesc->PackedField & 0x07) + 1)); + tableSize = (GIFWORD) (1L << ((GifImageDesc->PackedField & 0x07) + 1)); GifImageDesc->TableSize = tableSize; /* Read the Local Color Table */ for (i = 0; i < tableSize; i++) @@ -185,10 +185,10 @@ ReadGifImageDesc( /* ** Get LZW minimum Code Size */ - GifImageDesc->CodeSize = (WORD)*(*MemGif2)++; + GifImageDesc->CodeSize = (GIFWORD)*(*MemGif2)++; /*GifImageDesc->GIFImage = ReadDataSubBlocks(FpGif);*/ - if (!(GifImageDesc->GIFImage = (BYTE *)malloc((GifImageDesc->ImageWidth) * (GifImageDesc->ImageHeight)))) { + if (!(GifImageDesc->GIFImage = (GIFBYTE *)malloc((GifImageDesc->ImageWidth) * (GifImageDesc->ImageHeight)))) { printf("Out of memory"); exit(EXIT_FAILURE); } @@ -219,7 +219,7 @@ ReadGifImageDesc( int ReadGifGraphicControl( GIFGRAPHICCONTROL *GifGraphicControl, /* Pointer to GC Extension structure */ - BYTE **MemGif2 /* GIF image file input FILE stream */ + GIFBYTE **MemGif2 /* GIF image file input FILE stream */ ) { int i; @@ -244,7 +244,7 @@ ReadGifGraphicControl( int ReadGifPlainText( GIFPLAINTEXT *GifPlainText, /* Pointer to Plain Text Extension structure */ - BYTE **MemGif2 /* GIF image file input FILE stream */ + GIFBYTE **MemGif2 /* GIF image file input FILE stream */ ) { int i; @@ -283,7 +283,7 @@ ReadGifPlainText( int ReadGifApplication( GIFAPPLICATION *GifApplication, /* Pointer to Application Extension structure */ - BYTE **MemGif2 /* GIF image file input FILE stream */ + GIFBYTE **MemGif2 /* GIF image file input FILE stream */ ) { int i; @@ -321,7 +321,7 @@ ReadGifApplication( int ReadGifComment( GIFCOMMENT *GifComment, /* Pointer to GIF Comment Extension structure */ - BYTE **MemGif2 /* GIF image file input FILE stream */ + GIFBYTE **MemGif2 /* GIF image file input FILE stream */ ) { @@ -345,14 +345,14 @@ ReadGifComment( ** Returns: A NULL pointer if a memory allocation error occured, ** otherwise a valid pointer if no error occured. */ -static BYTE * -ReadDataSubBlocks(BYTE **MemGif2, /* GIF image file input FILE stream */ - WORD *DSize) +static GIFBYTE * +ReadDataSubBlocks(GIFBYTE **MemGif2, /* GIF image file input FILE stream */ + GIFWORD *DSize) { - BYTE *ptr1; /* Pointer used to "walk the heap" */ - BYTE *ptr2; /* Pointer used to mark the top of the heap */ - BYTE dataSize; /* Size of the current data sub-block being read */ - WORD bufSize; /* Total size of the Plain Text data buffer */ + GIFBYTE *ptr1; /* Pointer used to "walk the heap" */ + GIFBYTE *ptr2; /* Pointer used to mark the top of the heap */ + GIFBYTE dataSize; /* Size of the current data sub-block being read */ + GIFWORD bufSize; /* Total size of the Plain Text data buffer */ int tempcount = 0; bufSize = 0; /* The output buffer is empty */ @@ -360,9 +360,9 @@ ReadDataSubBlocks(BYTE **MemGif2, /* GIF image file input FILE stream dataSize = *(*MemGif2)++; /* Get the size of the first sub-block */ /* Allocate initial data buffer */ - if (!(ptr1 = ptr2 = (BYTE *) malloc((size_t)dataSize + 1))) { + if (!(ptr1 = ptr2 = (GIFBYTE *) malloc((size_t)dataSize + 1))) { printf("Out of memory. Allocation of memory for data sub-blocks for\neither Comment, Plain Text or Application Extensions failed"); - return((BYTE *) NULL); + return((GIFBYTE *) NULL); } for (;;) { @@ -381,8 +381,8 @@ ReadDataSubBlocks(BYTE **MemGif2, /* GIF image file input FILE stream break; /* Block Terminator encountered */ /* Increase the buffer size to accomodate the next sub-block */ - if (!(ptr1 = ptr2 = (BYTE *) realloc(ptr2, bufSize + dataSize + 1))) - return((BYTE *) NULL); + if (!(ptr1 = ptr2 = (GIFBYTE *) realloc(ptr2, bufSize + dataSize + 1))) + return((GIFBYTE *) NULL); ptr1 += bufSize; /* Move pointer to the end of the data */ diff --git a/hl/tools/gif2h5/hdf2gif.c b/hl/tools/gif2h5/hdf2gif.c index ae63e92..e32facb 100644 --- a/hl/tools/gif2h5/hdf2gif.c +++ b/hl/tools/gif2h5/hdf2gif.c @@ -45,20 +45,20 @@ usage(void) FILE *fpGif = NULL; int main(int argc , char **argv) { - BYTE *Image; + GIFBYTE *Image; void *edata; H5E_auto2_t func; /* compression structs */ - CHAR *HDFName = NULL; - CHAR *GIFName = NULL; + GIFCHAR *HDFName = NULL; + GIFCHAR *GIFName = NULL; - BYTE* b; + GIFBYTE* b; - BYTE GlobalPalette[256][3]; - BYTE Red[256]; - BYTE Green[256]; - BYTE Blue[256]; + GIFBYTE GlobalPalette[256][3]; + GIFBYTE Red[256]; + GIFBYTE Green[256]; + GIFBYTE Blue[256]; int RWidth, RHeight; int ColorMapSize, InitCodeSize, Background, BitsPerPixel; @@ -66,7 +66,7 @@ int main(int argc , char **argv) int i; int numcols = 0; - BYTE pc2nc[256] , r1[256] , g1[256] , b1[256]; + GIFBYTE pc2nc[256] , r1[256] , g1[256] , b1[256]; int arg_index = 2; int bool_is_image = 0; /* 0 = false , 1 = true */ @@ -110,7 +110,7 @@ int main(int argc , char **argv) { /* allocate space to store the image name */ size_t len = strlen(argv[arg_index]); - image_name = (CHAR*) malloc( len + 1); + image_name = (GIFCHAR*) malloc( len + 1); strcpy(image_name , argv[arg_index]); bool_is_image = 0; @@ -125,7 +125,7 @@ int main(int argc , char **argv) /* Do Endian Order testing and set Endian Order */ idx = 0x0001; - b = (BYTE *) &idx; + b = (GIFBYTE *) &idx; EndianOrder = (b[0] ? 1:0); if (!(fpGif = fopen(GIFName , "wb"))) @@ -164,7 +164,7 @@ int main(int argc , char **argv) goto out; } - Image = (BYTE*) malloc( (size_t) width * (size_t) height ); + Image = (GIFBYTE*) malloc( (size_t) width * (size_t) height ); if ( H5IMread_image( fid, image_name, Image ) < 0 ) goto out; @@ -174,7 +174,7 @@ int main(int argc , char **argv) if ( H5IMget_palette_info( fid, image_name, 0, pal_dims ) < 0 ) goto out; - pal = (BYTE*) malloc( (size_t) pal_dims[0] * (size_t) pal_dims[1] ); + pal = (GIFBYTE*) malloc( (size_t) pal_dims[0] * (size_t) pal_dims[1] ); if ( H5IMget_palette( fid, image_name, 0, pal ) < 0 ) goto out; @@ -211,9 +211,9 @@ int main(int argc , char **argv) numcols = 256; for (i = 0 ; i < numcols ; i++) { - Red[i] = (BYTE)(255 - i); - Green[i] = (BYTE)(255 - i); - Blue[i] = (BYTE)(255 - i); + Red[i] = (GIFBYTE)(255 - i); + Green[i] = (GIFBYTE)(255 - i); + Blue[i] = (GIFBYTE)(255 - i); } } else @@ -246,7 +246,7 @@ int main(int argc , char **argv) if (j==i) { /* wasn't found */ - pc2nc[i] = (BYTE)nc; + pc2nc[i] = (GIFBYTE)nc; r1[nc] = Red[i]; g1[nc] = Green[i]; b1[nc] = Blue[i]; diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c index 6f5ab58..ed3e9e9 100644 --- a/hl/tools/gif2h5/hdfgifwr.c +++ b/hl/tools/gif2h5/hdfgifwr.c @@ -51,7 +51,7 @@ #include "gif.h" -typedef BYTE byte; +typedef GIFBYTE byte; typedef long int count_int; #ifdef __STDC__ diff --git a/hl/tools/gif2h5/writehdf.c b/hl/tools/gif2h5/writehdf.c index b656c36..c2933c5 100644 --- a/hl/tools/gif2h5/writehdf.c +++ b/hl/tools/gif2h5/writehdf.c @@ -62,9 +62,9 @@ WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName) /* get some data from gifHead */ ImageCount = gifHead.ImageCount; #ifdef UNUSED - CommentCount = (WORD)gifHead.CommentCount; - ApplicationCount = (WORD)gifHead.ApplicationCount; - PlainTextCount = (WORD)gifHead.PlainTextCount; + CommentCount = (GIFWORD)gifHead.CommentCount; + ApplicationCount = (GIFWORD)gifHead.ApplicationCount; + PlainTextCount = (GIFWORD)gifHead.PlainTextCount; #endif /* UNUSED */ if ((file_id = H5Fcreate(HDFName , H5F_ACC_TRUNC , H5P_DEFAULT , H5P_DEFAULT)) < 0) { |