Xceed Real-Time Zip for .NET Documentation
Compress Method (Compressor)


Xceed.Compression Assembly > Xceed.Compression Namespace > Compressor Class : Compress Method
An array of bytes to compress. A maximum of count bytes are taken from this array and compressed.
The byte offset in buffer at which to begin taking the data to compress.
The maximum number of bytes to be taken from buffer.
Indicates if this call ends the stream of data to compress.
An array of bytes containing the compressed data. Can be empty.
Compresses an array of bytes.
Syntax
'Declaration
 
Public MustOverride Function Compress( _

   ByVal buffer() As Byte, _

   ByVal offset As Integer, _

   ByVal count As Integer, _

   ByVal endOfData As Boolean, _

   ByRef compressed() As Byte _

) As Integer
'Usage
 
Dim instance As Compressor

Dim buffer() As Byte

Dim offset As Integer

Dim count As Integer

Dim endOfData As Boolean

Dim compressed() As Byte

Dim value As Integer

 

value = instance.Compress(buffer, offset, count, endOfData, compressed)
public abstract int Compress( 

   byte[] buffer,

   int offset,

   int count,

   bool endOfData,

   out byte[] compressed

)

Parameters

buffer
An array of bytes to compress. A maximum of count bytes are taken from this array and compressed.
offset
The byte offset in buffer at which to begin taking the data to compress.
count
The maximum number of bytes to be taken from buffer.
endOfData
Indicates if this call ends the stream of data to compress.
compressed
An array of bytes containing the compressed data. Can be empty.

Return Value

The number of bytes written to the compressed parameter.
Remarks
When the first call to Compress is made, a compression "session" is created. This session remains opened as long as Compress is called with the parameter endOfData set to False.

During a compression session, the compression engine can choose to keep the data to compress in an internal buffer and return an empty array after a call to Compress. Many compression algorithms do this to get optimum compression by examining a certain number of bytes before compressing anything.

A call to Compress with an empty buffer or a count of zero tells the compression engine to flush its internal buffer and return the compressed data. This may degrade the compression ratio.

When Compress is called with the parameter endOfData set to True, the compression session is closed and all of the remaining compressed data is returned. The next call to Compress will create a new compression session.

The compressed array may have a Length greater than the number of bytes returned by the call to Compress.

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Compressor Class
Compressor Members