Sample code for 30+ languages & platforms
C++

Decompress Bytes

See more Compression Examples

Demonstrates how to decompress binary data.

Chilkat C++ Downloads

C++
#include <CkFileAccess.h>
#include <CkByteData.h>
#include <CkCompression.h>

void ChilkatSample(void)
    {
    bool success = false;

    //  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;
    }

    success = fac.WriteEntireFile("qa_output/decompressed.bmp",decompressedBytes);
    if (fac.get_LastMethodSuccess() != true) {
        std::cout << fac.lastErrorText() << "\r\n";
        return;
    }
    }