(Chilkat2-Python) Decompress Bytes
Demonstrates how to decompress binary data.
import sys
import chilkat2
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
# See this example to compress bytes: Compress Bytes
fac = chilkat2.FileAccess()
# compressedBytes is a memoryview
compressedBytes = fac.ReadEntireFile("qa_data/compressed/compressedBmp.dat")
if (fac.LastMethodSuccess != True):
print(fac.LastErrorText)
sys.exit()
compress = chilkat2.Compression()
compress.Algorithm = "deflate"
# decompressedBytes is a memoryview
decompressedBytes = compress.DecompressBytes(compressedBytes)
if (compress.LastMethodSuccess != True):
print(compress.LastErrorText)
sys.exit()
success = fac.WriteEntireFile("qa_output/decompressed.bmp",decompressedBytes)
if (fac.LastMethodSuccess != True):
print(fac.LastErrorText)
sys.exit()
|