(Swift) Decompress Bytes
Demonstrates how to decompress binary data.
func chilkatTest() {
// 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
let fac = CkoFileAccess()!
var compressedBytes: NSData
compressedBytes = fac.readEntireFile("qa_data/compressed/compressedBmp.dat")
if fac.lastMethodSuccess != true {
print("\(fac.lastErrorText!)")
return
}
let compress = CkoCompression()!
compress.algorithm = "deflate"
var decompressedBytes: NSData
decompressedBytes = compress.decompressBytes(compressedBytes)
if compress.lastMethodSuccess != true {
print("\(compress.lastErrorText!)")
return
}
var success: Bool = fac.writeEntireFile("qa_output/decompressed.bmp", fileData: decompressedBytes)
if fac.lastMethodSuccess != true {
print("\(fac.lastErrorText!)")
return
}
}
|