C# Class Moxie.PngEncoder.Deflater

This is the Deflater class. The deflater class compresses input with the deflate algorithm described in RFC 1951. It has several compression levels and three different strategies described below. This class is not thread safe. This is inherent in the API, due to the split of deflate and setInput. author of the original java version : Jochen Hoenicke
显示文件 Open project: openHPI/moodle-mod_teletask Class Usage Examples

Public Methods

Method Description
Deflate ( byte output ) : int

Deflates the current input block with to the given array.

Deflate ( byte output, int offset, int length ) : int

Deflates the current input block to the given array.

Deflater ( ) : System

Creates a new deflater with default compression level.

Deflater ( int level ) : System

Creates a new deflater with given compression level.

Deflater ( int level, bool noZlibHeaderOrFooter ) : System

Creates a new deflater with given compression level.

Finish ( ) : void

Finishes the deflater with the current input block. It is an error to give more input after this method was called. This method must be called to force all bytes to be flushed.

Flush ( ) : void

Flushes the current input block. Further calls to deflate() will produce enough output to inflate everything in the current input block. This is not part of Sun's JDK so I have made it package private. It is used by DeflaterOutputStream to implement flush().

GetLevel ( ) : int

Get current compression level

Reset ( ) : void

Resets the deflater. The deflater acts afterwards as if it was just created with the same compression level and strategy as it had before.

SetDictionary ( byte dictionary ) : void

Sets the dictionary which should be used in the deflate process. This call is equivalent to setDictionary(dict, 0, dict.Length).

SetDictionary ( byte dictionary, int index, int count ) : void

Sets the dictionary which should be used in the deflate process. The dictionary is a byte array containing strings that are likely to occur in the data which should be compressed. The dictionary is not stored in the compressed output, only a checksum. To decompress the output you need to supply the same dictionary again.

SetInput ( byte input ) : void

Sets the data which should be compressed next. This should be only called when needsInput indicates that more input is needed. If you call setInput when needsInput() returns false, the previous input that is still pending will be thrown away. The given byte array should not be changed, before needsInput() returns true again. This call is equivalent to setInput(input, 0, input.length).

SetInput ( byte input, int offset, int count ) : void

Sets the data which should be compressed next. This should be only called when needsInput indicates that more input is needed. The given byte array should not be changed, before needsInput() returns true again.

SetLevel ( int level ) : void

Sets the compression level. There is no guarantee of the exact position of the change, but if you call this when needsInput is true the change of compression level will occur somewhere near before the end of the so far given input.

SetStrategy ( DeflateStrategy strategy ) : void

Sets the compression strategy. Strategy is one of DEFAULT_STRATEGY, HUFFMAN_ONLY and FILTERED. For the exact position where the strategy is changed, the same as for SetLevel() applies.

Method Details

Deflate() public method

Deflates the current input block with to the given array.
public Deflate ( byte output ) : int
output byte /// The buffer where compressed data is stored ///
return int

Deflate() public method

Deflates the current input block to the given array.
/// If Finish() was previously called. /// /// If offset or length don't match the array length. ///
public Deflate ( byte output, int offset, int length ) : int
output byte /// Buffer to store the compressed data. ///
offset int /// Offset into the output array. ///
length int /// The maximum number of bytes that may be stored. ///
return int

Deflater() public method

Creates a new deflater with default compression level.
public Deflater ( ) : System
return System

Deflater() public method

Creates a new deflater with given compression level.
if lvl is out of range.
public Deflater ( int level ) : System
level int /// the compression level, a value between NO_COMPRESSION /// and BEST_COMPRESSION, or DEFAULT_COMPRESSION. ///
return System

Deflater() public method

Creates a new deflater with given compression level.
if lvl is out of range.
public Deflater ( int level, bool noZlibHeaderOrFooter ) : System
level int /// the compression level, a value between NO_COMPRESSION /// and BEST_COMPRESSION. ///
noZlibHeaderOrFooter bool /// true, if we should suppress the Zlib/RFC1950 header at the /// beginning and the adler checksum at the end of the output. This is /// useful for the GZIP/PKZIP formats. ///
return System

Finish() public method

Finishes the deflater with the current input block. It is an error to give more input after this method was called. This method must be called to force all bytes to be flushed.
public Finish ( ) : void
return void

Flush() public method

Flushes the current input block. Further calls to deflate() will produce enough output to inflate everything in the current input block. This is not part of Sun's JDK so I have made it package private. It is used by DeflaterOutputStream to implement flush().
public Flush ( ) : void
return void

GetLevel() public method

Get current compression level
public GetLevel ( ) : int
return int

Reset() public method

Resets the deflater. The deflater acts afterwards as if it was just created with the same compression level and strategy as it had before.
public Reset ( ) : void
return void

SetDictionary() public method

Sets the dictionary which should be used in the deflate process. This call is equivalent to setDictionary(dict, 0, dict.Length).
/// if SetInput () or Deflate () were already called or another dictionary was already set. ///
public SetDictionary ( byte dictionary ) : void
dictionary byte /// the dictionary. ///
return void

SetDictionary() public method

Sets the dictionary which should be used in the deflate process. The dictionary is a byte array containing strings that are likely to occur in the data which should be compressed. The dictionary is not stored in the compressed output, only a checksum. To decompress the output you need to supply the same dictionary again.
/// If SetInput () or Deflate() were already called or another dictionary was already set. ///
public SetDictionary ( byte dictionary, int index, int count ) : void
dictionary byte /// The dictionary data ///
index int /// The index where dictionary information commences. ///
count int /// The number of bytes in the dictionary. ///
return void

SetInput() public method

Sets the data which should be compressed next. This should be only called when needsInput indicates that more input is needed. If you call setInput when needsInput() returns false, the previous input that is still pending will be thrown away. The given byte array should not be changed, before needsInput() returns true again. This call is equivalent to setInput(input, 0, input.length).
/// if the buffer was finished() or ended(). ///
public SetInput ( byte input ) : void
input byte /// the buffer containing the input data. ///
return void

SetInput() public method

Sets the data which should be compressed next. This should be only called when needsInput indicates that more input is needed. The given byte array should not be changed, before needsInput() returns true again.
/// if the buffer was Finish()ed or if previous input is still pending. ///
public SetInput ( byte input, int offset, int count ) : void
input byte /// the buffer containing the input data. ///
offset int /// the start of the data. ///
count int /// the number of data bytes of input. ///
return void

SetLevel() public method

Sets the compression level. There is no guarantee of the exact position of the change, but if you call this when needsInput is true the change of compression level will occur somewhere near before the end of the so far given input.
public SetLevel ( int level ) : void
level int /// the new compression level. ///
return void

SetStrategy() public method

Sets the compression strategy. Strategy is one of DEFAULT_STRATEGY, HUFFMAN_ONLY and FILTERED. For the exact position where the strategy is changed, the same as for SetLevel() applies.
public SetStrategy ( DeflateStrategy strategy ) : void
strategy DeflateStrategy /// The new compression strategy. ///
return void