(Ruby) Decompress Bytes
Demonstrates how to decompress binary data.
require 'chilkat'
# 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 = Chilkat::CkFileAccess.new()
compressedBytes = Chilkat::CkByteData.new()
success = fac.ReadEntireFile("qa_data/compressed/compressedBmp.dat",compressedBytes)
if (fac.get_LastMethodSuccess() != true)
print fac.lastErrorText() + "\n";
exit
end
compress = Chilkat::CkCompression.new()
compress.put_Algorithm("deflate")
decompressedBytes = Chilkat::CkByteData.new()
success = compress.DecompressBytes(compressedBytes,decompressedBytes)
if (compress.get_LastMethodSuccess() != true)
print compress.lastErrorText() + "\n";
exit
end
success = fac.WriteEntireFile("qa_output/decompressed.bmp",decompressedBytes)
if (fac.get_LastMethodSuccess() != true)
print fac.lastErrorText() + "\n";
exit
end
|