sabato 23 marzo 2013

PackBits: decoder per la decompressione file


#include <cstdio>
#include <iostream>
#include <fstream>

using namespace std;

int main(int argc, char *argv[]){
ifstream in;
ofstream out;
unsigned char c, temp;
int dim;

in.open(argv[1]);
out.open(argv[2]);

while(1){
c = in.get();
cout << "Letto " << c << "\n";

if(c == 128)
break;
else if(c>128 && c<=257){
dim = 257 - c;
temp = in.get();
for(int i=0;i<dim;i++){
out.put(temp);
cout << "Stampato " << temp << "\n";
}
}
else if(c>=0 && c<128){
dim = c + 1;
for(int j=0;j<dim;j++){
temp = in.get();
out.put(temp);
cout << "Stampato " << temp << "\n";
}
}
}
in.close();
out.close();
}

Nessun commento:

Posta un commento