Skip to content
Andrew Lambert edited this page Nov 26, 2022 · 17 revisions

zlib.Deflate

Method Signatures

 Protected Function Deflate(Source As FolderItem,  Destination As FolderItem, CompressionLevel As Integer = zlib.Z_DEFAULT_COMPRESSION, Overwrite As Boolean = False, Encoding As Integer = zlib.DEFLATE_ENCODING) As Boolean
 Protected Function Deflate(Source As FolderItem,  Destination As Writeable,  CompressionLevel As Integer = zlib.Z_DEFAULT_COMPRESSION, Encoding As Integer = zlib.DEFLATE_ENCODING) As Boolean
 Protected Function Deflate(Source As MemoryBlock, Destination As FolderItem, CompressionLevel As Integer = zlib.Z_DEFAULT_COMPRESSION, Overwrite As Boolean = False, Encoding As Integer = zlib.DEFLATE_ENCODING) As Boolean
 Protected Function Deflate(Source As MemoryBlock, Destination As Writeable,  CompressionLevel As Integer = zlib.Z_DEFAULT_COMPRESSION, Encoding As Integer = zlib.DEFLATE_ENCODING) As Boolean
 Protected Function Deflate(Source As Readable,    Destination As FolderItem, CompressionLevel As Integer = zlib.Z_DEFAULT_COMPRESSION, Overwrite As Boolean = False, Encoding As Integer = zlib.DEFLATE_ENCODING) As Boolean
 Protected Function Deflate(Source As Readable,    Destination As Writeable,  CompressionLevel As Integer = zlib.Z_DEFAULT_COMPRESSION, Encoding As Integer = zlib.DEFLATE_ENCODING) As Boolean
 Protected Function Deflate(Source As FolderItem,  CompressionLevel As Integer = zlib.Z_DEFAULT_COMPRESSION, Encoding As Integer = zlib.DEFLATE_ENCODING) As MemoryBlock
 Protected Function Deflate(Source As MemoryBlock, CompressionLevel As Integer = zlib.Z_DEFAULT_COMPRESSION, Encoding As Integer = zlib.DEFLATE_ENCODING) As MemoryBlock
 Protected Function Deflate(Source As Readable,    CompressionLevel As Integer = zlib.Z_DEFAULT_COMPRESSION, Encoding As Integer = zlib.DEFLATE_ENCODING) As MemoryBlock

Parameters

Name Type Comment
Source FolderItem, Readable, or MemoryBlock The data to compress
Destination FolderItem or Writeable The file or stream to which compressed data should be written. Methods which return a MemoryBlock do not have this parameter
CompressionLevel Integer Optional. If specified, the compression level to use (0=none, 1=fast, 9=best)
Overwrite Boolean Optional. If True, the Destination FolderItem will be overwritten if it exists. Only those methods with FolderItem destinations have this parameter
Encoding Integer Optional. If specified, the output encoding to be used by the compressor

Return value

Returns True if there were no errors writing to a Writeable or FolderItem; or, a MemoryBlock containing the compressed data.

Remarks

Compresses data from the Source argument into the Destination argument; methods without a Destination argument return the compressed data instead.

Examples

Compress a string into a string:

  Dim data As String = "hello, world!"
  Dim deflated As String = zlib.Deflate(data)

Compress a string into a file:

  Dim data As String = "hello, world!"
  Dim deflated As FolderItem = SpecialFolder.Desktop.Child("example.bin")
  If Not zlib.Deflate(data, deflated) Then
    MsgBox("Deflate error!")
  End If

Compress a file into a string:

  Dim data As FolderItem = SpecialFolder.Desktop.Child("example.bin")
  Dim deflated As String = zlib.Deflate(data)

See also

Entry-level points of interest denoted by "☜"



Clone this wiki locally