summaryrefslogtreecommitdiffstats
path: root/README
blob: 181b0a1e80101421a927910cd48de40295c90a8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
README:  Tcl
    This is the Tcl 8.4.19 source distribution.
	http://tcl.sourceforge.net/
    You can get any source release of Tcl from the file distributions
    link at the above URL.

Contents
--------
    1. Introduction
    2. Documentation
    3. Compiling and installing Tcl
    4. Development tools
    5. Tcl newsgroup
    6. The Tcler's Wiki
    7. Mailing lists
    8. Support and Training
    9. Tracking Development
    10. Thank You

1. Introduction
---------------
Tcl provides a powerful platform for creating integration applications that
tie together diverse applications, protocols, devices, and frameworks.
When paired with the Tk toolkit, Tcl provides the fastest and most powerful
way to create GUI applications that run on PCs, Unix, and the Macintosh.
Tcl can also be used for a variety of web-related tasks and for creating
powerful command languages for applications.

Tcl is maintained, enhanced, and distributed freely by the Tcl community.
The home for Tcl/Tk releases and bug/patch database is on SourceForge:

	http://tcl.sourceforge.net/

with the Tcl Developer Xchange hosted at:

	http://www.tcl.tk/

Tcl is a freely available open source package.  You can do virtually
anything you like with it, such as modifying it, redistributing it,
and selling it either in whole or in part.  See the file
"license.terms" for complete information.

2. Documentation
----------------

Extensive documentation is available at our website.
The home page for this release, including new features, is
	http://www.tcl.tk/software/tcltk/8.4.html

Detailed release notes can be found at the file distributions page
by clicking on the relevant version.
	http://sourceforge.net/projects/tcl/files/

Information about Tcl itself can be found at
	http://www.tcl.tk/about/

There have been many Tcl books on the market.  Many are mentioned in the Wiki:
	http://wiki.tcl.tk/_/ref?N=25206

To view the complete set of reference manual entries for Tcl 8.4 online,
visit the URL:
	http://www.tcl.tk/man/tcl8.4/

2a. Unix Documentation
----------------------

The "doc" subdirectory in this release contains a complete set of
reference manual entries for Tcl.  Files with extension ".1" are for
programs (for example, tclsh.1); files with extension ".3" are for C
library procedures; and files with extension ".n" describe Tcl
commands.  The file "doc/Tcl.n" gives a quick summary of the Tcl
language syntax.  To print any of the man pages on Unix, cd to the
"doc" directory and invoke your favorite variant of troff using the
normal -man macros, for example

		ditroff -man Tcl.n

to print Tcl.n.  If Tcl has been installed correctly and your "man" program
supports it, you should be able to access the Tcl manual entries using the
normal "man" mechanisms, such as

		man Tcl

2b. Windows Documentation
-------------------------

The "doc" subdirectory in this release contains a complete set of Windows
help files for Tcl.  Once you install this Tcl release, a shortcut to the
Windows help Tcl documentation will appear in the "Start" menu:

	Start | Programs | Tcl | Tcl Help

3. Compiling and installing Tcl
-------------------------------

There are brief notes in the unix/README, win/README, and macosx/README about
compiling on these different platforms.  There is additional information
about building Tcl from sources at

	http://www.tcl.tk/doc/howto/compile.html

4. Development tools
---------------------------

ActiveState produces a high quality set of commercial quality development
tools that is available to accelerate your Tcl application development.
Tcl Dev Kit builds on the earlier TclPro toolset and provides a debugger,
static code checker, single-file wrapping utility, bytecode compiler and
more.  More information can be found at

	http://www.ActiveState.com/Tcl

5. Tcl newsgroup
----------------

There is a USENET news group, "comp.lang.tcl", intended for the exchange of
information about Tcl, Tk, and related applications.  The newsgroup is a
great place to ask general information questions.  For bug reports, please
see the "Support and bug fixes" section below.

6. The Tcler's Wiki
-------------------

A Wiki-based open community site covering all aspects of Tcl/Tk is at:

	http://wiki.tcl.tk/

It is dedicated to the Tcl programming language and its extensions.  A
wealth of useful information can be found there.  It contains code
snippets, references to papers, books, and FAQs, as well as pointers to
development tools, extensions, and applications.  You can also recommend
additional URLs by editing the wiki yourself.

7. Mailing lists
----------------

Several mailing lists are hosted at SourceForge to discuss development or
use issues (like Macintosh and Windows topics).  For more information and
to subscribe, visit:

	http://sourceforge.net/projects/tcl/

and go to the Mailing Lists page.

8. Support and Training
------------------------

We are very interested in receiving bug reports, patches, and suggestions
for improvements.  We prefer that you send this information to us via the
bug form at SourceForge, rather than emailing us directly.  The bug
database is at:

	http://tcl.sourceforge.net/

The bug form was designed to give uniform structure to bug reports as
well as to solicit enough information to minimize followup questions.

We will log and follow-up on each bug, although we cannot promise a
specific turn-around time.  Enhancements, reported via the Feature
Requests form at the same web site, may take longer and may not happen
at all unless there is widespread support for them (we're trying to
slow the rate at which Tcl/Tk turns into a kitchen sink).  It's very
difficult to make incompatible changes to Tcl/Tk at this point, due to
the size of the installed base.

The Tcl community is too large for us to provide much individual support
for users.  If you need help we suggest that you post questions to
comp.lang.tcl.  We read the newsgroup and will attempt to answer esoteric
questions for which no one else is likely to know the answer.  In addition,
see the following page on the Wiki for links to other organizations that offer
Tcl/Tk training:

	http://wiki.tcl.tk/training

9. Tracking Development
-----------------------

Tcl is developed in public.  To keep an eye on how Tcl is changing, see
	http://core.tcl.tk/

10. Thank You
-------------

We'd like to express our thanks to the Tcl community for all the
helpful suggestions, bug reports, and patches we have received.
Tcl/Tk has improved vastly and will continue to do so with your help.
March 1992 **
+** Author: James D. Murray, Anaheim, CA, USA **
+** C Compilers: Borland C++ v2.0, Microsoft C v6.00a **
+** **
+** GIFHEAD displays all real information contained within a GIF image **
+** file, including all color tables and extension block information. **
+** GIFHEAD reads both GIF 87a abd 89a-format files. **
+** **
+** Copyright (C) 1991-92 by Graphics Software Labs. All rights reserved. **
+\****************************************************************************/
+#include <stdio.h>
+#include "gif.h"
+/* #include <hdf.h> */
+
+#define VERSION "1.00"
+extern int EndianOrder;
+
+GIFTOMEM
+Gif2Mem(MemGif)
+BYTE *MemGif;
+{
+ /*
+ ** The gif structure outline for passing data to memory
+ ** is given in gif.h
+ ** These pointers are redunant, should take them out in ver. 2
+ */
+ GIFHEAD *gifHead; /* GIF Header structure */
+ GIFIMAGEDESC **gifImageDesc; /* Logical Image Descriptor struct */
+ GIFPLAINTEXT **gifPlainText; /* Plain Text Extension structure */
+ GIFAPPLICATION **gifApplication; /* Application Extension structure */
+ GIFCOMMENT **gifComment; /* Comment Extension structure */
+ GIFGRAPHICCONTROL **gifGraphicControl; /* Graphic Control Extension strct */
+
+ GIFTOMEM GifMemoryStruct;
+
+
+
+ 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 */
+
+ /* Allocate memory for the GIF structures */
+ /* Plug the structs into GifMemoryStruct at the end */
+ /****************************************************/
+ if (!(gifHead = (GIFHEAD *)malloc(sizeof(GIFHEAD))))
+ {
+ printf("Could not allocate memory for gifHead\n");
+ exit(-1);
+ }
+
+ /*
+ ** The next three have to grow dynamically so we leave them
+ ** for now and let realloc handle it later on.
+ */
+ gifImageDesc = NULL;
+ gifPlainText = NULL;
+ gifGraphicControl = NULL;
+ gifComment = NULL;
+ gifApplication = NULL;
+
+ /******************************/
+ /* Memory allocation complete */
+
+
+ /* Carry out Endian Testing and set Endian Order */
+ w = 0x0001;
+ b = (BYTE *) &w;
+ EndianOrder = (b[0] ? 1 : 0);
+
+ /* Read the GIF image file header information */
+ ReadGifHeader(gifHead, &MemGif);
+
+ /* Check for FILE stream error */
+ /*
+ if (ferror(fpGif))
+ {
+ fputs("GIFHEAD: Error reading header information!\n", stderr);
+ exit(-3);
+ }
+ */
+
+ /*
+ ** Identify, read, and display block information.
+ */
+ ImageCount = ImageArray = 0;
+ CommentCount = CommentArray = 0;
+ ApplicationCount = ApplicationArray = 0;
+ PlainTextCount = PlainTextArray = 0;
+ GCEflag = 0;
+
+ for (;;)
+ {
+ Identifier = *MemGif++;
+
+ switch (Identifier)
+ {
+ case 0x3B: /* Trailer */
+ /* The counts are stored to make it easier while
+ ** putting stuff into the HDF file and then
+ ** deallocating space.
+ */
+ gifHead->ImageCount = ImageCount;
+ gifHead->CommentCount = CommentCount;
+ gifHead->ApplicationCount = ApplicationCount;
+ gifHead->PlainTextCount = PlainTextCount;
+
+ /* putting stuff into the gif2mem structure */
+ GifMemoryStruct.GifHeader = gifHead;
+ GifMemoryStruct.GifImageDesc = gifImageDesc;
+ GifMemoryStruct.GifPlainTextExtension = gifPlainText;
+ GifMemoryStruct.GifApplicationExtension = gifApplication;
+ GifMemoryStruct.GifCommentExtension = gifComment;
+ GifMemoryStruct.GifGraphicControlExtension = gifGraphicControl;
+
+ /* return the struct */
+ return GifMemoryStruct;
+
+
+
+ case 0x2C: /* Image Descriptor */
+ /* If there was no image descriptor before this increase image count.
+ ** If an imagedescriptor was present, reset GCEflag
+ */
+ if (GCEflag == 0)
+ ImageCount++;
+ else
+ GCEflag = 0;
+
+ if (ImageCount > ImageArray) {
+ aTemp = ImageArray;
+ ImageArray = (ImageArray << 1) + 1;
+ if (!(gifImageDesc = (GIFIMAGEDESC **)realloc(gifImageDesc , sizeof(GIFIMAGEDESC *) * ImageArray)))
+ {
+ printf("Out of memory!");
+ exit(-1);
+ }
+ if (!(gifGraphicControl = (GIFGRAPHICCONTROL **)realloc(gifGraphicControl , sizeof(GIFGRAPHICCONTROL *) * ImageArray)))
+ {
+ printf("Out of memory!");
+ exit(-1);
+ }
+
+ for (j = aTemp ; j < ImageArray ; j++) {
+ gifGraphicControl[j] = NULL;
+ gifImageDesc[j] = NULL;
+ }
+ }
+
+ if(!(gifImageDesc[ImageCount-1] = (GIFIMAGEDESC*)malloc(sizeof(GIFIMAGEDESC))))
+ {
+ printf("Out of memory!");
+ exit(-1);
+ }
+
+
+ if (ReadGifImageDesc(gifImageDesc[ImageCount-1], &MemGif) == -1)
+ fputs("Error reading Image Descriptor information\n", stderr);
+
+ /*
+ ** Decompress the Image
+ */
+ gifImageDesc[ImageCount-1]->Image = Decompress(gifImageDesc[ImageCount-1] , gifHead);
+ free(gifImageDesc[ImageCount-1]->GIFImage);
+
+ /*
+ ** Convert the local palette into an HDF compatible palette
+ ** In case the local color table is present, it is written out as the HDFPalette
+ ** If it is absent the global table is written as the HDFPalette.
+ */
+ if (!((gifImageDesc[ImageCount-1]->PackedField) & 0x80))
+ {
+ /* Check to see if the global color table exists.... */
+ if (gifHead->PackedField & 0x80) {
+ for (i=0 ; i<gifHead->TableSize ; i++)
+ {
+ gifImageDesc[ImageCount-1]->HDFPalette[i][0] = gifHead->HDFPalette[i][0];
+ gifImageDesc[ImageCount-1]->HDFPalette[i][1] = gifHead->HDFPalette[i][1];
+ gifImageDesc[ImageCount-1]->HDFPalette[i][2] = gifHead->HDFPalette[i][2];
+ }
+ }
+ gifImageDesc[ImageCount-1]->TableSize = gifHead->TableSize;
+ }
+
+ break;
+
+ case 0x21: /* Extension Block */
+ Label = *MemGif++;
+ switch (Label)
+ {
+ case 0x01: /* Plain Text Extension */
+ puts("Plain Text Extension\n");
+
+ PlainTextCount++;
+ if (PlainTextCount > PlainTextArray)
+ PlainTextArray = (PlainTextArray << 1) + 1;
+
+ if (!(gifPlainText = (GIFPLAINTEXT **)realloc(gifPlainText , sizeof(GIFPLAINTEXT *) * PlainTextArray)))
+ {
+ printf("Out of memory!");
+ exit(-1);
+ }
+
+ if(!(gifPlainText[PlainTextCount - 1] = (GIFPLAINTEXT*)malloc(sizeof(GIFPLAINTEXT))))
+ {
+ printf("Out of memory!");
+ exit(-1);
+ }
+
+
+
+ if (ReadGifPlainText(gifPlainText[PlainTextCount - 1], &MemGif))
+ fprintf(stderr,
+ "Error reading Plain Text Extension information.\n");
+
+ break;
+
+ case 0xFE: /* Comment Extension */
+ CommentCount++;
+ if (CommentCount > CommentArray)
+ CommentArray = (CommentArray << 1) + 1;
+
+ if (!(gifComment = (GIFCOMMENT **)realloc(gifComment , sizeof(GIFCOMMENT *) * CommentArray)))
+ {
+ printf("Out of memory!");
+ exit(-1);
+ }
+
+ if(!(gifComment[CommentCount - 1] = (GIFCOMMENT *)malloc(sizeof(GIFCOMMENT))))
+ {
+ printf("Out of memory!");
+ exit(-1);
+ }
+
+
+ if (ReadGifComment(gifComment[CommentCount - 1], &MemGif))
+ fprintf(stderr,
+ "Error reading Comment Extension information\n");
+ break;
+
+ case 0xF9: /* Graphic Control Extension */
+ if (GCEflag == 0 )
+ ImageCount++;
+
+ GCEflag = 1;
+
+ if (ImageCount > ImageArray) {
+ aTemp = ImageArray;
+ ImageArray = (ImageArray << 1) + 1;
+ if (!(gifGraphicControl = (GIFGRAPHICCONTROL **)realloc(gifGraphicControl , sizeof(GIFGRAPHICCONTROL *) * ImageArray)))
+ {
+ printf("Out of memory!");
+ exit(-1);
+ }
+ if (!(gifImageDesc = (GIFIMAGEDESC **)realloc(gifImageDesc , sizeof(GIFIMAGEDESC *) * ImageArray)))
+ {
+ printf("Out of memory!");
+ exit(-1);
+ }
+ for (j = aTemp ; j < ImageArray ; j++) {
+ gifGraphicControl[j] = NULL;
+ gifImageDesc[j] = NULL;
+ }
+ }
+
+ if(!(gifGraphicControl[ImageCount-1] = (GIFGRAPHICCONTROL*)malloc(sizeof(GIFGRAPHICCONTROL))))
+ {
+ printf("Out of memory!");
+ exit(-1);
+ }
+
+
+ if (ReadGifGraphicControl(gifGraphicControl[ImageCount-1], &MemGif))
+ fprintf(stderr,
+ "Error reading Graphic Control Extension information\n");
+
+ if (!*MemGif++ == 0)
+ fprintf(stderr,
+ "Error reading Graphic Control Extension\n");
+
+ break;
+
+ case 0xFF: /* Application Extension */
+ ApplicationCount++;
+ if (ApplicationCount > ApplicationArray)
+ ApplicationArray = (ApplicationArray << 1) + 1;
+
+ if (!(gifApplication = (GIFAPPLICATION **)realloc(gifApplication , sizeof(GIFAPPLICATION *) * ApplicationArray)))
+ {
+ printf("Out of memory!");
+ exit(-1);
+ }
+
+ if(!(gifApplication[ApplicationCount - 1] = (GIFAPPLICATION *)malloc(sizeof(GIFAPPLICATION))))
+ {
+ printf("Out of memory!");
+ exit(-1);
+ }
+
+
+ if (ReadGifApplication(gifApplication[ApplicationCount - 1], &MemGif))
+ fprintf(stderr,
+ "Error reading Application Extension information\n");
+ break;
+
+ default:
+
+ printf("Unknown Extension Label: 0x%02x\n", Label);
+ break;
+ }
+ break;
+ default:
+ fprintf(stderr, "Unknown Block Separator Character: 0x%02x\n",
+ Identifier);
+ }
+ }
+
+
+}
diff --git a/hl/tools/gif2h5/gifread.c b/hl/tools/gif2h5/gifread.c
new file mode 100644
index 0000000..1196241
--- /dev/null
+++ b/hl/tools/gif2h5/gifread.c
@@ -0,0 +1,382 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "gif.h"
+
+int EndianOrder;
+int i;
+
+
+WORD
+GetWord (MemGif)
+BYTE *MemGif;
+{
+ register 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;
+{
+ 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.
+*/
+int
+ReadGifHeader(GifHead, MemGif2)
+GIFHEAD *GifHead; /* Pointer to GIF header structure */
+BYTE **MemGif2; /* GIF image file input FILE stream */
+{
+ register 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(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;
+ /* 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++)
+ {
+ GifHead->HDFPalette[i][0] = *(*MemGif2)++;
+ GifHead->HDFPalette[i][1] = *(*MemGif2)++;
+ GifHead->HDFPalette[i][2] = *(*MemGif2)++;
+ }
+ }
+
+ /* Check for a FILE stream error */
+ /*
+ if (ferror(FpGif))
+ return(-1);
+ */
+
+ return(0); /* No FILE stream error occured */
+}
+
+
+/*
+** Read a GIF Local Image Descriptor.
+**
+** This function reads the Local Image Descriptor, and Local Color
+** Table (if any) from a GIF image file. The information is stored
+** in a GIFIMAGEDESC structure.
+**
+** Note that the ImageSeparator field value in the GIFIMAGEDESC
+** structure is assigned by the function calling ReadGifImageDesc().
+**
+** Returns: -1 if a FILE stream error occured during the read,
+** otherwise 0 if no error occured.
+*/
+int
+ReadGifImageDesc(GifImageDesc, MemGif2)
+GIFIMAGEDESC *GifImageDesc; /* Pointer to GIF image descriptor structure */
+BYTE **MemGif2; /* GIF image file input FILE stream */
+{
+ register WORD i; /* Loop counter */
+ WORD tableSize; /* Number of entries in the Local Color Table */
+ BYTE Interlace; /* PackedField & 0x20 gives information on interlacing */
+ BYTE *TempPtr;
+ int ch , ch1;
+
+ GifImageDesc->TableSize = 0;
+ for (i = 0 ; i < 9 ; i++) {
+ GifImageDesc->GIDDump[i] = *(*MemGif2)++;
+ }
+
+ /*
+ ** Get the relevant fields. I need ImageWidth and Height actively hence I have
+ ** taken information from those fields. I intend to keep the GifImageDesc data
+ ** structure as it is so that anyone needing the rest of the fields can do so
+ ** quickly.
+ */
+
+ if (EndianOrder == 1) /* LittleEndian */
+ {
+ GifImageDesc->ImageWidth = (WORD) (GifImageDesc->GIDDump[4] & 0xFF);
+ GifImageDesc->ImageWidth |= (WORD) ((GifImageDesc->GIDDump[5] & 0xFF) << 0x08);
+
+ GifImageDesc->ImageHeight = (WORD) (GifImageDesc->GIDDump[6] & 0xFF);
+ GifImageDesc->ImageHeight |= (WORD) ((GifImageDesc->GIDDump[7] & 0xFF) << 0x08);
+
+ }
+ else
+ {
+ GifImageDesc->ImageWidth = (WORD) (GifImageDesc->GIDDump[4] & 0xFF);
+ GifImageDesc->ImageWidth = ((WORD) (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->PackedField = GifImageDesc->GIDDump[8];
+
+ /* Interlace = GifImageDesc->PackedField & 0x20; */
+
+ /* Check if a Local Color Table is present */
+ if (GifImageDesc->PackedField & 0x80)
+ {
+ /* Read number of color table entries */
+ tableSize = (WORD) (1L << ((GifImageDesc->PackedField & 0x07) + 1));
+ GifImageDesc->TableSize = tableSize;
+ /* Read the Local Color Table */
+ for (i = 0; i < tableSize; i++)
+ {
+ GifImageDesc->HDFPalette[i][0] = *(*MemGif2)++;
+ GifImageDesc->HDFPalette[i][1] = *(*MemGif2)++;
+ GifImageDesc->HDFPalette[i][2] = *(*MemGif2)++;
+ }
+ }
+
+ /*
+ ** Get LZW minimum Code Size
+ */
+ GifImageDesc->CodeSize = (WORD)*(*MemGif2)++;
+
+ /*GifImageDesc->GIFImage = ReadDataSubBlocks(FpGif);*/
+ if (!(GifImageDesc->GIFImage = (BYTE *)malloc((GifImageDesc->ImageWidth) * (GifImageDesc->ImageHeight)))) {
+ printf("Out of memory");
+ exit(-1);
+ }
+
+
+ TempPtr = GifImageDesc->GIFImage;
+ do
+ {
+ ch = ch1 = (int)*(*MemGif2)++;
+ while (ch--) *TempPtr++ = *(*MemGif2)++;
+ }
+ while (ch1);
+
+
+ return(0); /* No FILE stream error occured */
+}
+
+
+/*
+** Read a GIF Graphic Control Extension block.
+**
+** Note that the Introducer and Label field values in the GIFGRAPHICCONTROL
+** structure are assigned by the function calling ReadGifGraphicControl().
+**
+** Returns: -1 if a FILE stream error occured during the read,
+** otherwise 0 if no error occured.
+*/
+int
+ReadGifGraphicControl(GifGraphicControl, MemGif2)
+GIFGRAPHICCONTROL *GifGraphicControl; /* Pointer to GC Extension structure */
+BYTE **MemGif2; /* GIF image file input FILE stream */
+{
+
+
+ for (i = 0 ; i < 5 ; i++) {
+ GifGraphicControl->GCEDump[i] = *(*MemGif2)++;
+ }
+
+ return(0); /* No FILE stream error occured */
+}
+
+
+/*
+** Read a GIF Plain Text Extension block.
+**
+** Note that the Introducer and Label field values in the GIFLPLAINTEXT
+** structure are assigned by the function calling ReadGifPlainText().
+**
+** Returns: -1 if a FILE stream error occured during the read,
+** otherwise 0 if no error occured.
+*/
+int
+ReadGifPlainText(GifPlainText, MemGif2)
+GIFPLAINTEXT *GifPlainText; /* Pointer to Plain Text Extension structure */
+BYTE **MemGif2; /* GIF image file input FILE stream */
+{
+ for (i = 0 ; i < 13 ; i++) {
+ GifPlainText->PTEDump[i] = *(*MemGif2)++;
+ }
+
+ /* Read in the Plain Text data sub-blocks */
+ if (!(GifPlainText->PlainTextData = ReadDataSubBlocks(MemGif2 , &(GifPlainText->DataSize))))
+ return(1);
+
+ /*
+ GifPlainText->Terminator = 0;
+ */
+
+ /* Check for a FILE stream error */
+ /*
+ if (ferror(FpGif))
+ return(-1);
+ */
+
+ return(0); /* No FILE stream error occured */
+}
+
+
+/*
+** Read a GIF Application Extension block.
+**
+** Note that the Introducer and Label field values in the GIFAPPLICATION
+** structure are assigned by the function calling ReadGifApplication().
+**
+** Returns: -1 if a FILE stream error occured during the read,
+** otherwise 0 if no error occured.
+*/
+int
+ReadGifApplication(GifApplication, MemGif2)
+GIFAPPLICATION *GifApplication; /* Pointer to Application Extension structure */
+BYTE **MemGif2; /* GIF image file input FILE stream */
+{
+ for (i = 0 ; i < 12 ; i++) {
+ GifApplication->AEDump[i] = *(*MemGif2)++;
+ }
+
+ /* Read in the Plain Text data sub-blocks */
+ if (!(GifApplication->ApplicationData = ReadDataSubBlocks(MemGif2 , &(GifApplication->DataSize))))
+ return(1);
+ /*
+ GifApplication->Terminator = 0;
+ */
+
+ /* Check for a FILE stream error */
+ /*
+ if (ferror(FpGif))
+ return(-1);
+ */
+
+ return(0); /* No FILE stream error occured */
+}
+
+
+/*
+** Read a GIF Comment Extension block.
+**
+** Note that the Introducer and Label field values in the GIFCOMMENT
+** structure are assigned by the function calling ReadGifComment().
+**
+** Returns: -1 if a FILE stream error occured during the read,
+** otherwise 0 if no error occured.
+*/
+int
+ReadGifComment(GifComment, MemGif2)
+GIFCOMMENT *GifComment; /* Pointer to GIF Comment Extension structure */
+BYTE **MemGif2; /* GIF image file input FILE stream */
+{
+
+ /* Read in the Plain Text data sub-blocks */
+ if (!(GifComment->CommentData = ReadDataSubBlocks(MemGif2 , &(GifComment->DataSize))))
+ return(1);
+
+ GifComment->Terminator = 0;
+
+ return(0); /* No FILE stream error occured */
+}
+
+
+/*
+** Read one or more GIF data sub-blocks and write the information
+** to a buffer.
+**
+** A GIF "sub-block" is a single count byte followed by 1 to 255
+** additional data bytes.
+**
+** Returns: A NULL pointer if a memory allocation error occured,
+** otherwise a valid pointer if no error occured.
+*/
+static BYTE *
+ReadDataSubBlocks(MemGif2 , DSize)
+BYTE **MemGif2; /* GIF image file input FILE stream */
+WORD *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 */
+ int tempcount = 0;
+
+ bufSize = 0; /* The output buffer is empty */
+
+ dataSize = *(*MemGif2)++; /* Get the size of the first sub-block */
+
+ /* Allocate initial data buffer */
+ if (!(ptr1 = ptr2 = (BYTE *) malloc(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);
+ }
+ for (;;)
+ {
+ tempcount++;
+ bufSize += (dataSize); /* Running total of the buffer size */
+ *DSize = bufSize;
+
+ /* *ptr1++ = dataSize; /* Write the data count */
+ while (dataSize--) /* Read/write the Plain Text data */
+ *ptr1++ = *(*MemGif2)++;
+
+ /* Check if there is another data sub-block */
+ if ((dataSize = *(*MemGif2)++) == 0)
+ 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);
+
+
+ ptr1 += bufSize; /* Move pointer to the end of the data */
+
+
+ }
+
+ /**ptr1++ = (BYTE) NULL; /* Add NULL to simulate Terminator value */
+ *ptr1++ = '\0';
+
+ return(ptr2); /* Return a pointer to the sub-block data */
+}
+
+
+
+
+
diff --git a/hl/tools/gif2h5/hdf2gif.c b/hl/tools/gif2h5/hdf2gif.c
new file mode 100644