home *** CD-ROM | disk | FTP | other *** search
- #include <fstream>
- #include "jpegdeco.h"
- #include "jpdehuff.h"
-
- using namespace std ;
-
- JpegHuffmanDecoder table ;
-
- main (int argc, char *argv [])
- {
- unsigned int bytes ;
-
- if (argc != 3)
- {
- cerr << "Usage: " << argv [0] << " input-file output-file" << endl ;
- return 1 ;
- }
-
- ifstream input ;
- input.open (argv [1], ios::binary) ;
- if (! input)
- {
- cerr << "Can't open input file" << endl ;
- return 1 ;
- }
-
- JpegDecoder decoder (input) ;
- table.ReadTable (decoder) ;
-
- ofstream output ;
- output.open (argv [2]) ;
- if (! output)
- {
- cerr << "Can't open output file" << endl ;
- return 1 ;
- }
-
- UBYTE1 data = table.Decode (decoder) ;
- bytes = 0 ;
- while (! input.eof ())
- {
- ++ bytes ;
- if (bytes % 1000 == 0)
- cout << bytes << " Bytes\r" ;
- output.write ((char *) &data, 1) ;
- data = table.Decode (decoder) ;
- }
- cout << bytes << " bytes" << endl ;
- output.write ((char *) &data, 1) ;
-
- input.close () ;
- output.close () ;
- return 0 ;
- }
-