(C++) Decompress Bytes
Demonstrates how to decompress binary data.
#include <CkFileAccess.h>
#include <CkByteData.h>
#include <CkCompression.h>
void ChilkatSample(void)
{
// 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
CkFileAccess fac;
CkByteData compressedBytes;
success = fac.ReadEntireFile("qa_data/compressed/compressedBmp.dat",compressedBytes);
if (fac.get_LastMethodSuccess() != true) {
std::cout << fac.lastErrorText() << "\r\n";
return;
}
CkCompression compress;
compress.put_Algorithm("deflate");
CkByteData decompressedBytes;
success = compress.DecompressBytes(compressedBytes,decompressedBytes);
if (compress.get_LastMethodSuccess() != true) {
std::cout << compress.lastErrorText() << "\r\n";
return;
}
bool success = fac.WriteEntireFile("qa_output/decompressed.bmp",decompressedBytes);
if (fac.get_LastMethodSuccess() != true) {
std::cout << fac.lastErrorText() << "\r\n";
return;
}
}
|