diff options
author | Bill Wendling <wendling@ncsa.uiuc.edu> | 2001-07-24 17:51:22 (GMT) |
---|---|---|
committer | Bill Wendling <wendling@ncsa.uiuc.edu> | 2001-07-24 17:51:22 (GMT) |
commit | e685336ab13081f8e4a92b7a4a9b6bf022ae5b23 (patch) | |
tree | c6858498dd0d2357f6736df7f2095b5453394bf1 /hl/tools/gif2h5/gifread.c | |
parent | 953a75e4f164e881a145ca669f1ec34dd1357d05 (diff) | |
download | hdf5-e685336ab13081f8e4a92b7a4a9b6bf022ae5b23.zip hdf5-e685336ab13081f8e4a92b7a4a9b6bf022ae5b23.tar.gz hdf5-e685336ab13081f8e4a92b7a4a9b6bf022ae5b23.tar.bz2 |
[svn-r4254]
Purpose:
Reformatting
Description:
Reformatted the code so that it's much clearer and conforms to the
HDF5 coding standards. Changed the function headers to use the ANSI
style instead of the KnR style. Kept the use of typedef's such as
"unsigned char" being "BYTE" and so on since of of this code is
copied from some other place and that's the style they use...I didn't
want to break things.
Platforms tested:
It compiles fine on Linux, but there aren't any tests for this
package, so...
Diffstat (limited to 'hl/tools/gif2h5/gifread.c')
-rw-r--r-- | hl/tools/gif2h5/gifread.c | 126 |
1 files changed, 64 insertions, 62 deletions
diff --git a/hl/tools/gif2h5/gifread.c b/hl/tools/gif2h5/gifread.c index cb033d9..39043f3 100644 --- a/hl/tools/gif2h5/gifread.c +++ b/hl/tools/gif2h5/gifread.c @@ -1,85 +1,87 @@ +/* + * Copyright (C) 2001 National Center for Supercomputing Applications + * All rights reserved. + */ #include <stdio.h> #include <stdlib.h> + #include "gif.h" int EndianOrder; -static BYTE * ReadDataSubBlocks(BYTE **MemGif2, WORD *DSize); +static BYTE *ReadDataSubBlocks(BYTE **MemGif2, WORD *DSize); WORD -GetWord (MemGif) -BYTE *MemGif; +GetWord(BYTE *MemGif) { - WORD w; - if (EndianOrder == 1) /* LittleEndian */ - { - w = (WORD) (*MemGif++ & 0xFF); - w |= (WORD) ((*MemGif++ & 0xFF) << 0x08); - } - else - { - w = (WORD) (*MemGif++ & 0xFF); - w = ((WORD) (*MemGif++ & 0xFF)) | (w << 0x08); - } - return w; + WORD w; + + if (EndianOrder == 1) { + /* LittleEndian */ + w = (WORD) (*MemGif++ & 0xFF); + w |= (WORD) ((*MemGif++ & 0xFF) << 0x08); + } else { + w = (WORD) (*MemGif++ & 0xFF); + w = ((WORD) (*MemGif++ & 0xFF)) | (w << 0x08); + } + + return w; } BYTE -GetByte (MemGif) -BYTE *MemGif; +GetByte(BYTE *MemGif) { - return *MemGif; + return *MemGif; } /* -** Read a GIF image BYTE Header. -** -** This function reads the Header, Logical Screen Descriptor, and -** Global Color Table (if any) from a GIF image file. The information -** is stored in a GIFHEAD structure. -** -** Returns: -1 if a FILE stream error occured during the read, -** otherwise 0 if no error occured. -*/ + * Read a GIF image BYTE Header. + * + * This function reads the Header, Logical Screen Descriptor, and + * Global Color Table (if any) from a GIF image file. The information + * is stored in a GIFHEAD structure. + * + * Returns: -1 if a FILE stream error occured during the read, + * otherwise 0 if no error occured. + */ int -ReadGifHeader(GifHead, MemGif2) -GIFHEAD *GifHead; /* Pointer to GIF header structure */ -BYTE **MemGif2; /* GIF image file input FILE stream */ +ReadGifHeader(GIFHEAD *GifHead, /* Pointer to GIF header structure */ + BYTE **MemGif2) /* GIF image file input FILE stream */ { - WORD i; /* Loop counter */ + WORD i; /* Loop counter */ WORD tableSize; /* Number of entires in the Global Color Table */ - - GifHead->TableSize = 0; - for (i = 0 ; i < 6 ; i++) { - GifHead->HeaderDump[i] = *(*MemGif2)++; - } - if (strncmp((const char *)GifHead->HeaderDump , "GIF" , 3)) { - printf("The file does not appear to be a valid GIF file.\n"); - exit(-1); - } - - for (i = 0 ; i < 7 ; i++) { - GifHead->LSDDump[i] = *(*MemGif2)++; - } - GifHead->PackedField = GifHead->LSDDump[4]; - /* Check if a Global Color Table is present */ - if (GifHead->PackedField & 0x80) - { + GifHead->TableSize = 0; + for (i = 0 ; i < 6 ; i++) { + GifHead->HeaderDump[i] = *(*MemGif2)++; + } + + if (strncmp((const char *)GifHead->HeaderDump , "GIF" , 3)) { + printf("The file does not appear to be a valid GIF file.\n"); + exit(-1); + } + + for (i = 0 ; i < 7 ; i++) { + GifHead->LSDDump[i] = *(*MemGif2)++; + } + + GifHead->PackedField = GifHead->LSDDump[4]; + + /* 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)); - GifHead->TableSize = tableSize; + GifHead->TableSize = tableSize; + /* Read the Global Color Table */ - /* - ** There are some changes made here apart from just - ** reading in the global color table as would - ** seem intuitively obvious. - ** The colors are stored in the bottom part of the - ** palette as opposed to the top - */ - for (i = 0; i < tableSize; i++) - { + /* + * There are some changes made here apart from just reading in the + * global color table as would seem intuitively obvious. The colors + * are stored in the bottom part of the palette as opposed to the top + */ + + for (i = 0; i < tableSize; i++) { GifHead->HDFPalette[i][0] = *(*MemGif2)++; GifHead->HDFPalette[i][1] = *(*MemGif2)++; GifHead->HDFPalette[i][2] = *(*MemGif2)++; @@ -87,12 +89,12 @@ BYTE **MemGif2; /* GIF image file input FILE stream */ } /* Check for a FILE stream error */ - /* +#if 0 if (ferror(FpGif)) - return(-1); - */ + return -1; +#endif /* 0 */ - return(0); /* No FILE stream error occured */ + return 0; /* No FILE stream error occured */ } |