-
-
Notifications
You must be signed in to change notification settings - Fork 3
zlib.ZStream.Constructor
' General purpose constructors
Sub Constructor(Source As MemoryBlock, CompressionLevel As Integer = zlib.Z_DEFAULT_COMPRESSION, Encoding As Integer = zlib.Z_DETECT)
Sub Constructor(Source As BinaryStream, CompressionLevel As Integer = zlib.Z_DEFAULT_COMPRESSION, Encoding As Integer = zlib.Z_DETECT)
' Constructors available to subclasses
Protected Sub Constructor(Engine As zlib.Deflater, Destination As Writeable)
Protected Sub Constructor(Engine As zlib.Inflater, Source As Readable)
Name | Type | Comment |
---|---|---|
Source |
MemoryBlock , BinaryStream
|
A zero-length MemoryBlock or BinaryStream to use for output, or a >0 length MemoryBlock or BinaryStream to use for input |
CompressionLevel | Integer | Optional. The compression level for the output. Valid levels are 1 (fast) to 9 (best) |
Encoding | Integer | Optional. The type of compression. One of DEFLATE_ENCODING , GZIP_ENCODING , or RAW_ENCODING . Other values are possible for special cases; refer to the zlib documentation on the "windowBits" parameter for details. |
Name | Type | Comment |
---|---|---|
Engine | Deflater | An instance of Deflater that is ready to receive uncompressed input. |
Destination | Writeable | The stream to which compressed output will be written. |
Name | Type | Comment |
---|---|---|
Engine | Inflater | An instance of Inflater that is ready to receive compressed input. |
Source | Readable | The stream from which compressed input is to be read. |
Constructs a ZStream from the Source
MemoryBlock or BinaryStream. If the Source
as a MemoryBlock has a Size
of zero, or as a BinaryStream its Length
is equal to its Position
, then compressed data will be written to the Source
; otherwise, the Source
will be used as input to be decompressed.
The protected constructors are for advanced users with special cases. If that's not you then you probably want the ZStream.Create and ZStream.Open shared methods instead.
To use the protected constructors create a custom subclass of ZStream
and use the Super keyword (i.e. Super.Constructor()
).
This example creates a ZStream from a zero-length MemoryBlock and writes(compresses) as string into it, then it creates a second ZStream for reading the compressed string:
Dim data As New MemoryBlock(0)
Dim z As New zlib.ZStream(data)
z.Write("Hello, world!")
z.Close
z = New zlib.ZStream(data)
MsgBox(z.ReadAll)
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.