(C++) Compress Bytes
Demonstrates how to compress binary data.
#include <CkFileAccess.h>
#include <CkByteData.h>
#include <CkCompression.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkFileAccess fac;
CkByteData fileBytes;
success = fac.ReadEntireFile("qa_data/bmp/big.bmp",fileBytes);
if (fac.get_LastMethodSuccess() != true) {
std::cout << fac.lastErrorText() << "\r\n";
return;
}
CkCompression compress;
compress.put_Algorithm("deflate");
CkByteData compressedBytes;
success = compress.CompressBytes(fileBytes,compressedBytes);
if (compress.get_LastMethodSuccess() != true) {
std::cout << compress.lastErrorText() << "\r\n";
return;
}
bool success = fac.WriteEntireFile("qa_output/compressedBmp.dat",compressedBytes);
if (fac.get_LastMethodSuccess() != true) {
std::cout << fac.lastErrorText() << "\r\n";
return;
}
}
|