All pastes #827968 Raw Edit

Miscellany

public cpp v1 · immutable
#827968 ·published 2007-12-22 04:08 UTC
rendered paste body
#include <iostream>#include <fstream>#include "include/zlib.h"using namespace std;int main(void) {    /*char buffer[4096];    char compressed[4096];    ifstream file("test.bmp", ios::in | ios::binary | ios::ate);    int size = file.tellg();    file.seekg(ios::beg);    memset(buffer, 0, 4096);        file.read(buffer, size);    cout << buffer;    int out = 4096;    compress((Bytef*)compressed, (uLongf*)&out, (const Bytef*)buffer, size);    std::ofstream outfile("test.dat");    outfile.write(compressed, out);    return 0;*/    /*char buffer[4096];    char uncompressed[4096];    std::ifstream file("test.dat", ios::in|ios::binary|ios::ate);    int size = file.tellg();    file.seekg(ios::beg);    memset(buffer, 0, 4096);    file.read(buffer, size);    int out = 4096;    uncompress((Bytef*)uncompressed, (uLongf*)&out, (const Bytef*)buffer, 1000);    std::ofstream outfile("out.bmp");    outfile.write(uncompressed, out);    return 0;*/    z_stream strm;    strm.zalloc = Z_NULL;    strm.zfree = Z_NULL;    strm.opaque = Z_NULL;    strm.avail_in = 0;    strm.next_in = Z_NULL;    inflateInit(&strm);    char buffer[4096];    char uncompressed[4096];    std::ifstream file("test.dat", ios::in|ios::binary|ios::ate);    int size = file.tellg();    file.seekg(ios::beg);    memset(buffer, 0, 4096);    file.read(buffer, size);    int out = 4096;    do {        strm.avail_in = size;        strm.next_in = (Bytef *)buffer;        strm.avail_out = 4096;        strm.next_out = (Bytef *)uncompressed;        inflate(&strm, Z_NO_FLUSH);    }while(strm.avail_out == 0);    inflateEnd(&strm);    return 0;}