Sample code for 30+ languages & platforms
Xojo Plugin

Compress Bytes

See more Compression Examples

Demonstrates how to compress binary data.

Chilkat Xojo Plugin Downloads

Xojo Plugin
Dim success As Boolean
success = False

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

Dim fac As New Chilkat.FileAccess

Dim fileBytes As MemoryBlock
fileBytes = fac.ReadEntireFile("qa_data/bmp/big.bmp")
If (fac.LastMethodSuccess <> True) Then
    System.DebugLog(fac.LastErrorText)
    Return
End If

Dim compress As New Chilkat.Compression
compress.Algorithm = "deflate"

Dim compressedBytes As MemoryBlock
compressedBytes = compress.CompressBytes(fileBytes)
If (compress.LastMethodSuccess <> True) Then
    System.DebugLog(compress.LastErrorText)
    Return
End If

success = fac.WriteEntireFile("qa_output/compressedBmp.dat",compressedBytes)
If (fac.LastMethodSuccess <> True) Then
    System.DebugLog(fac.LastErrorText)
    Return
End If