IPWorks ZIP 2020 Python Edition

Questions / Feedback?

compress_block Method

Compresses a block of data.

Syntax

def compress_block(last_block: bool) -> None: ...

Remarks

This method compresses the block of data specified by input_data.

The compress_block and decompress_block methods operate on blocks (chunks) of data. The methods may be used to compress and decompress data as it becomes available.

Note that when using blocks of data the output_data property is not applicable. Instead data is made available through the on_compressed_data and on_decompressed_data events.

If all data is available ahead of time compress_data and decompress_data may be called instead.

Compress Data

Set input_data to the current block to be compressed. Next call compress_block to compress the current block. Note that compress_block takes a LastBlock parameter. If the block of data is the final block to be compressed set this to True. For all other blocks set this to False.

During compression the on_compressed_data event will fire with the compressed data. Note that this event may not fire for every call to compress_block due to the way the compression algorithm operates. For example:


zipstream.InputDataB = MyDecompressedData;
zipstream.CompressBlock();
Data is accumulated inside the on_compressed_data event:
private static void Zipstream_OnCompressedData(object sender, ZipstreamCompressedDataEventArgs e)
{
  DoSomethingWith(e.DataB);
}

Note that output_data is not applicable when compressing block data.

Decompress Data

Set input_data to the current block to be decompressed. Next call decompress_block to decompress the current block.

During decompression the on_decompressed_data event will fire with the decompressed data. Note that this event may not fire for every call to decompress_block due to the way the decompression algorithm operates. For example:


zipstream.InputDataB = MyCompressedData;
zipstream.DecompressBlock();
Data is accumulated inside the on_decompressed_data event:
private static void Zipstream_OnDecompressedData(object sender, ZipstreamDecompressedDataEventArgs e)
{
  DoSomethingWith(e.DataB);
}

Note that output_data is not applicable when decompressing block data.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks ZIP 2020 Python Edition - Version 20.0 [Build 8300]