Trying to Compress Already-Compressed Data

If a file or data does not compress, and the “compressed” result is slightly larger than the uncompressed input, then… This is typical if one tries to compress already-compressed data. For example, the JPG image format is itself a compression algorithm. The more something is compressed, the more the data resembles a sequence of random bytes. Compression algorithms work by […]

C++ String Compression: PPMD, Deflate, BZip2, LZW

This C++ example demonstrates string compression using four different compression algorithms: PPMD, Deflate, BZip2, and LZW. void TestCompression(const char *algorithm) { CkCompression comp; comp.put_Algorithm(algorithm); printf (“algorithm: %s\n”,algorithm); CkByteData compressedData; comp.CompressString(“abc abc abc abc abc abc abc abc abc abc abc 123 123 abc 123”,compressedData); // Get the compressed data: const unsigned char *pCompressedData = compressedData.getBytes(); unsigned long numBytes = compressedData.getSize(); […]

VB.NET Compress String to Byte Array

Demonstrates how to use Chilkat.Compression to compress a string to a byte array: Private Sub CompressStringToBytes() Dim compress As New Chilkat.Compression() ‘ Any string argument automatically begins a 30-day trial. Dim success As Boolean success = compress.UnlockComponent(“30-day trial”) If (success <> True) Then MsgBox(“Compression component unlock failed”) Exit Sub End If ‘ Use the “deflate” algorithm, which is the algorithm […]