Skip to content

BZip2.Compressor.Compress

Andrew Lambert edited this page Nov 27, 2022 · 3 revisions

BZip2.Compressor.Compress

Method Signature

  Function Compress(ReadFrom As Readable, WriteTo As Writeable, ReadCount As Integer = -1) As Boolean

Parameters

Name Type Comment
ReadFrom Readable The stream from which to read uncompressed data.
WriteTo Writeable The stream to which compressed data will be written.
ReadCount Integer Optional. If specified, the number of uncompressed bytes to read.

Remarks

This method processes uncompressed bytes from ReadFrom into the compressor, and writes any compressed bytes that were emitted to WriteTo. If ReadCount is specified then exactly ReadCount uncompressed bytes are read; otherwise uncompressed bytes will continue to be read until ReadFrom.EOF=True.

The unprocessed portion of the input is retained by the compressor until a subsequent call to this method.

BZip2 does not necessarily consume uncompressed data immediately. The "sliding window" determines the size of the compression buffer, and the size of the compression buffer determines how many uncompressed bytes have to be consumed in order to emit one or more compressed bytes.

If the compressor needed more uncompressed bytes than were provided then zero bytes will be emitted and Avail_Out will be >0. Call Compress again with more uncompressed bytes until Avail_Out=0. If there are no more uncompressed bytes then call Compressor.Finish.

Clone this wiki locally