C# Класс 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.

Наследование: System.IO.Stream
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
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.

Описание методов

Dispose() защищенный Метод

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
Результат void

Flush() публичный Метод

Flush the stream.
public Flush ( ) : void
Результат void

Read() публичный Метод

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.
Результат int

Seek() публичный Метод

Calling this method always throws a NotImplementedException.
public Seek ( long offset, System origin ) : long
offset long
origin System
Результат long

SetLength() публичный Метод

Calling this method always throws a NotImplementedException.
public SetLength ( long value ) : void
value long
Результат void

UncompressBuffer() публичный статический Метод

Uncompress a byte array into a byte array.
public static UncompressBuffer ( byte compressed ) : byte[]
compressed byte /// A buffer containing ZLIB-compressed data. ///
Результат byte[]

UncompressString() публичный статический Метод

Uncompress a byte array into a single string.
public static UncompressString ( byte compressed ) : String
compressed byte /// A buffer containing ZLIB-compressed data. ///
Результат String

Write() публичный Метод

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.
Результат void

ZlibStream() публичный Метод

public ZlibStream ( System stream ) : System
stream System
Результат System