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