A Sandcastle Documented Class Library
LzwEncoder Class
GIFCOMPR.C - GIF Image compression routines Lempel-Ziv compression based on 'compress'. GIF modifications by David Rowley (mgardi@watdcsu.waterloo.edu) Adapted from Jef Poskanzer's Java port by way of J. M. G. Elliott. K Weiner 12/00 GIF Image compression - modified 'compress' Based on: compress.c - File compression ala IEEE Computer, June 1984. By Authors: Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas) Jim McKie (decvax!mcvax!jim) Steve Davies (decvax!vax135!petsd!peora!srd) Ken Turkowski (decvax!decwrl!turtlevax!ken) James A. Woods (decvax!ihnp4!ames!jaw) Joe Orost (decvax!vax135!petsd!joe) Algorithm: use open addressing double hashing (no chaining) on the prefix code / next character combination. We do a variant of Knuth's algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime secondary probe. Here, the modular division first probe is gives way to a faster exclusive-or manipulation. Also do block compression with an adaptive reset, whereby the code table is cleared when the compression ratio decreases, but after the table fills. The variable-length output codes are re-sized at this point, and a special CLEAR code is generated for the decompressor. Late addition: construct the table according to file size for noticeable speed improvement on small files. Please direct questions about this implementation to ames!jaw. Inputs: code: A n_bits-bit integer. If == -1, then EOF. This assumes that n_bits =< wordsize - 1. Outputs: Outputs code to the file. Assumptions: Chars are 8 bits long. Algorithm: Maintain a BITS character long buffer (so that 8 codes will fit in it exactly). Use the VAX insv instruction to insert each code in turn. When the buffer fills up empty it and start over. Modified by Simon Bridewell, June-August 2009: Downloaded from http://www.thinkedge.com/blogengine/post/2008/02/20/Animated-GIF-Encoder-for-NET-Update.aspx http://www.thinkedge.com/BlogEngine/file.axd?file=NGif_src2.zip * Corrected FxCop code analysis errors. * Documentation comments converted to .net XML comments. * Updated to use .net 2.0 generics - use List instead of byte[] TODO: maybe this belongs in TableBasedImageData?
Declaration Syntax
C#Visual BasicVisual C++
public class LzwEncoder
Public Class LzwEncoder
public ref class LzwEncoder
All MembersConstructorsMethods


Encodes the data and writes it to the supplied output stream.

Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.)
Serves as a hash function for a particular type. GetHashCode()()() is suitable for use in hashing algorithms and data structures like a hash table.
(Inherited from Object.)
Gets the Type of the current instance.
(Inherited from Object.)
Creates a shallow copy of the current Object.
(Inherited from Object.)
Returns a String that represents the current Object.
(Inherited from Object.)
Inheritance Hierarchy

Assembly: GifComponents (Module: GifComponents) Version: 0.1.3594.26453