Path: dvinci!alberta!ubc-cs!uw-beaver!cornell!mailrus!iuvax!watmath!watdcsu!mgardi
From: mgardi@watdcsu.waterloo.edu (M.Gardi - ICR)
Newsgroups: comp.graphics
Subject: GIF Compression source - enjoy
Message-ID: <5518@watdcsu.waterloo.edu>
Date: 9 Feb 89 23:30:20 GMT
Distribution: comp
Organization: U of Waterloo, Ontario
Lines: 749
Keywords: gif, lempel-ziv, compuserve

Here is some source for GIF image compression.  It is set up for MSDOS,
but is trivial to modify for non-DOS machines (change the open for write
to "w" instead of "wb", remove the define for MSDOS, etc).

The source started out as the lempel-ziv 'compress' routine, and was modified
to output GIF files.

To use the GIFEncode function, define a function 'GetPixel' that
takes an X and Y co-ordinate (as int's) and returns the colour index
of that pixel.  Then call GIFEncode with the following:

	GIFEncode( Fname,          /* The filename to write */
	           GWidth,        /* The width of the bitmap - an int */
		   GHeight,        /* The height of the bitmap - an int */
		   GInterlace,     /* TRUE if you want the image to be
				      interlaced, FALSE otherwise */
	           Background,     /* The colour index of the background */
		   BitsPerPixel,   /* The number of bits of color per
				      pixel in the palette you specified.
				      If your palette has 256 colours,
				      it should be '8', 32 should be '5',
				      etc */
		   Red, Green, Blue, /* Pointers to arrays of int's,
					containing the R, G and B values
					of the colour palette */
	
		   GetPixel );	   /* a pointer to a function that returns
				      the index of the colour at the
				      co-ordinates passed */


**************************************************************************
Modifications 1.3.97 by Arnd Kobus to make it compile on gcc for OS/2.
Adopted the function declarations and created the gif.h file with
prototypes.

