#include "eydrle.hh" namespace EydTools { void EydRle::uncompress(){ EydLib::BitGroup data; EydLib::BitReader bitread(_cellsize, 256); bitread.open(_input_file); unsigned char c; bitread.readDirect(&c, 1); //TODO: fixer cell_size en fonction de "c"; if (c != _cellsize){ printf("WARNING : File cellsize is %d, but uncompressing with %d\n",c, _cellsize); } EydLib::BitWriter bitwrite(_cellsize,256); bitwrite.open(_output_file); EydLib::BitUncompressor uncompressor(_cellsize); printf("File opened\n"); bool done=false; std::vector record; while(!done){ try{ data = bitread.read(); uncompressor.append(data); if (uncompressor.hasContent()){ std::list uncompressedData = uncompressor.flush(); std::list::iterator uncmpDataIt; for(uncmpDataIt = uncompressedData.begin(); uncmpDataIt != uncompressedData.end(); uncmpDataIt++){ bitwrite.write((*uncmpDataIt)); // cellule } } } catch (EydLib::eBitReaderEndOfFile& e) { done = true; // on flushe le contenu de record // uncompressor.flushRleData(); std::list uncompressedData = uncompressor.flush(); std::list::iterator uncmpDataIt; for(uncmpDataIt = uncompressedData.begin(); uncmpDataIt != uncompressedData.end(); uncmpDataIt++){ bitwrite.write((*uncmpDataIt)); // cellule } } catch (std::exception& e){ printf("ERROR\n"); } } printf("uncompression done\n"); bitread.close(); bitwrite.close(); printf("file closed\n"); } }