C# Class SharpGIS.ZLib.ZlibStream

Represents a Zlib stream for compression or decompression.

The ZlibStream is a Decorator on a . It adds ZLIB compression or decompression to any stream.

Using this stream, applications can compress or decompress data via stream Read and Write operations. Either compresssion or decompression can occur through either reading or writing. The compression format used is ZLIB, which is documented in IETF RFC 1950, "ZLIB Compressed Data Format Specification version 3.3". This implementation of ZLIB always uses DEFLATE as the compression method. (see IETF RFC 1951, "DEFLATE Compressed Data Format Specification version 1.3.")

The ZLIB format allows for varying compression methods, window sizes, and dictionaries. This implementation always uses the DEFLATE compression method, a preset dictionary, and 15 window bits by default.

This class is similar to DeflateStream, except that it adds the RFC1950 header and trailer bytes to a compressed stream when compressing, or expects the RFC1950 header and trailer bytes when decompressing. It is also similar to the GZipStream.

Inheritance: System.IO.Stream
Show file Open project: sozialhelden/wheelmap-wp7 Class Usage Examples

Public Methods

Method Description
Flush ( ) : void

Flush the stream.

Read ( byte buffer, int offset, int count ) : int

Read data from the stream.

If you wish to use the ZlibStream to compress data while reading, you can create a ZlibStream with CompressionMode.Compress, providing an uncompressed data stream. Then call Read() on that ZlibStream, and the data read will be compressed. If you wish to use the ZlibStream to decompress data while reading, you can create a ZlibStream with CompressionMode.Decompress, providing a readable compressed data stream. Then call Read() on that ZlibStream, and the data will be decompressed as it is read.

A ZlibStream can be used for Read() or Write(), but not both.

Seek ( long offset, System origin ) : long

Calling this method always throws a NotImplementedException.

SetLength ( long value ) : void

Calling this method always throws a NotImplementedException.

UncompressBuffer ( byte compressed ) : byte[]

Uncompress a byte array into a byte array.

UncompressString ( byte compressed ) : String

Uncompress a byte array into a single string.

Write ( byte buffer, int offset, int count ) : void

Write data to the stream.

If you wish to use the ZlibStream to compress data while writing, you can create a ZlibStream with CompressionMode.Compress, and a writable output stream. Then call Write() on that ZlibStream, providing uncompressed data as input. The data sent to the output stream will be the compressed form of the data written. If you wish to use the ZlibStream to decompress data while writing, you can create a ZlibStream with CompressionMode.Decompress, and a writable output stream. Then call Write() on that stream, providing previously compressed data. The data sent to the output stream will be the decompressed form of the data written.

A ZlibStream can be used for Read() or Write(), but not both.

ZlibStream ( System stream ) : System

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Dispose the stream.

This may or may not result in a Close() call on the captive stream. See the constructors that have a leaveOpen parameter for more information.

Method Details

Dispose() protected method

Dispose the stream.
This may or may not result in a Close() call on the captive stream. See the constructors that have a leaveOpen parameter for more information.
protected Dispose ( bool disposing ) : void
disposing bool
return void

Flush() public method

Flush the stream.
public Flush ( ) : void
return void

Read() public method

Read data from the stream.

If you wish to use the ZlibStream to compress data while reading, you can create a ZlibStream with CompressionMode.Compress, providing an uncompressed data stream. Then call Read() on that ZlibStream, and the data read will be compressed. If you wish to use the ZlibStream to decompress data while reading, you can create a ZlibStream with CompressionMode.Decompress, providing a readable compressed data stream. Then call Read() on that ZlibStream, and the data will be decompressed as it is read.

A ZlibStream can be used for Read() or Write(), but not both.

public Read ( byte buffer, int offset, int count ) : int
buffer byte The buffer into which the read data should be placed.
offset int the offset within that data array to put the first byte read.
count int the number of bytes to read.
return int

Seek() public method

Calling this method always throws a NotImplementedException.
public Seek ( long offset, System origin ) : long
offset long
origin System
return long

SetLength() public method

Calling this method always throws a NotImplementedException.
public SetLength ( long value ) : void
value long
return void

UncompressBuffer() public static method

Uncompress a byte array into a byte array.
public static UncompressBuffer ( byte compressed ) : byte[]
compressed byte /// A buffer containing ZLIB-compressed data. ///
return byte[]

UncompressString() public static method

Uncompress a byte array into a single string.
public static UncompressString ( byte compressed ) : String
compressed byte /// A buffer containing ZLIB-compressed data. ///
return String

Write() public method

Write data to the stream.

If you wish to use the ZlibStream to compress data while writing, you can create a ZlibStream with CompressionMode.Compress, and a writable output stream. Then call Write() on that ZlibStream, providing uncompressed data as input. The data sent to the output stream will be the compressed form of the data written. If you wish to use the ZlibStream to decompress data while writing, you can create a ZlibStream with CompressionMode.Decompress, and a writable output stream. Then call Write() on that stream, providing previously compressed data. The data sent to the output stream will be the decompressed form of the data written.

A ZlibStream can be used for Read() or Write(), but not both.

public Write ( byte buffer, int offset, int count ) : void
buffer byte The buffer holding data to write to the stream.
offset int the offset within that data array to find the first byte to write.
count int the number of bytes to write.
return void

ZlibStream() public method

public ZlibStream ( System stream ) : System
stream System
return System