(CkPython) Compress Bytes
Demonstrates how to compress binary data.
import sys
import chilkat
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
fac = chilkat.CkFileAccess()
fileBytes = chilkat.CkByteData()
success = fac.ReadEntireFile("qa_data/bmp/big.bmp",fileBytes)
if (fac.get_LastMethodSuccess() != True):
print(fac.lastErrorText())
sys.exit()
compress = chilkat.CkCompression()
compress.put_Algorithm("deflate")
compressedBytes = chilkat.CkByteData()
success = compress.CompressBytes(fileBytes,compressedBytes)
if (compress.get_LastMethodSuccess() != True):
print(compress.lastErrorText())
sys.exit()
success = fac.WriteEntireFile("qa_output/compressedBmp.dat",compressedBytes)
if (fac.get_LastMethodSuccess() != True):
print(fac.lastErrorText())
sys.exit()
|