-
-
Notifications
You must be signed in to change notification settings - Fork 3
zlib.Deflater.Deflate
Function Deflate(Data As MemoryBlock, Flushing As Integer = zlib.Z_NO_FLUSH) As MemoryBlock
Function Deflate(ReadFrom As Readable, WriteTo As Writeable, Flushing As Integer = zlib.Z_NO_FLUSH, ReadCount As Integer = -1) As Boolean
Name | Type | Comment |
---|---|---|
Data | MemoryBlock |
The next chunk of data to compress. |
Flushing | Integer |
Optional. If specified, indicates whether (and how) pending output should be flushed (see remarks.) |
Name | Type | Comment |
---|---|---|
ReadFrom | Readable |
The stream from which to read uncompressed data. |
WriteTo | Writeable |
The stream to which compressed data will be written. |
Flushing | Integer |
Optional. If specified, indicates whether (and how) pending output should be flushed (see remarks.) |
ReadCount | Integer |
Optional. If specified, the number of uncompressed bytes to read. |
There are two versions of this method:
Processes uncompressed bytes in Data
into the compressor, and returns any compressed bytes that were emitted. If there was no output then a zero-length MemoryBlock
is returned.
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
.
In both versions the unprocessed portion of the input is retained by the compressor until a subsequent call to this method.
Deflate
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 Deflate
again with more uncompressed bytes until Avail_Out=0
. If there are no more uncompressed bytes then call Deflate
with zero uncompressed bytes (or specify Nil
as the ReadFrom
parameter) and Z_FINISH
as the Flushing
parameter.
The Flushing
parameter may be one of the following constants
Name | Comment |
---|---|
Z_NO_FLUSH |
The default, this allows deflate to decide how much data to accumulate before producing output. |
Z_SYNC_FLUSH |
All pending output is flushed to the output buffer and the output is aligned on a byte boundary. |
Z_PARTIAL_FLUSH |
All pending output is flushed to the output buffer, but the output is not aligned to a byte boundary. |
Z_BLOCK |
A deflate block is completed and emitted, but the output is not aligned on a byte boundary. |
Z_FULL_FLUSH |
Like Z_SYNC_FLUSH , and the compression state is reset so that decompression can restart from this point. |
Z_FINISH |
All remaining output is aligned on a byte boundary and written to the output buffer. |
Wiki home | Project page | Bugs | Become a sponsor
Text and code examples are Copyright ©2014-24 Andrew Lambert, offered under the CC BY-SA 3.0 License.