VB example Visual C++ example Delphi example
The Compress method compresses data entirely in memory. It can compress data in a single call, or it can be called multiple times to compress data in a streaming fashion.
Parameter | Description |
---|---|
vaSource | The data to compress. All OLE automation variant types are supported, including string and byte array variants. |
bEndOfData | This parameter indicates whether or not there is more data to compress. If you only have a single block of data to compress, set this parameter to True. The library will then immediately compress return all the data provided in the vaSource parameter and return the resulting compressed data. If you can only provide a portion of the data to compress in the vaSource parameter and will provide more data later in a subsequent call to the Compress method, set this parameter to False. In this case, the library will compress and return as much data as possible. When the final portion of the data to compress has been provided, set the bEndOfData parameter to True. The method will then return the final portion of the compressed data. |
The return value is a byte array variant containing the compressed data.
The CompressionFormat property allows you to specify the format of the compressed data, which not only determines whether or not the compressed data should contain a checksum such as Adler-32 or CRC , but also in most cases implies which compression algorithm will be used by the library.
ToString and FromString
When calling the Compress method with the bEndOfData parameter specified as False, you cannot call any other Xceed Streaming Compression control method (of the same instance of the control) until you have completed processing a stream of data by calling the Compress method with the bEndOfData parameter specified as True.
With Visual Basic, it is often necessary to convert the resulting compressed data from a byte array variant to a native VB byte array before saving it or transmitting it. VB6 makes it particularly easy to do the conversion: If you have a variant named (for example) CompressedData, you can convert it to a native VB byte array with the following code:
Visual Basic | ![]() |
---|---|
|
With Microsoft Access, you can place the compressed data in either a Memo field or an OLE Object field. Using an OLE Object field in a table is the easiest: You can directly assign your data to the field and conversion is automatic. To assign the compressed data variant to a Memo field, use the "AppendChunk" function in Access.
Declaration (DXceedStreamingCompression) | ![]() |
---|---|
HRESULT Compress |
Declaration (IXceedStreamingCompression) | ![]() |
---|---|
|