home *** CD-ROM | disk | FTP | other *** search
- #include <fstream>
-
- #include "xbmdecod.h"
- #include "bmpencod.h"
-
- using namespace std ;
-
- void Usage (int argc, char *argv [])
- {
- char *program ;
- if (argc == 0)
- program = "DECODER" ;
- else
- program = argv [0] ;
-
- cout << program << " input-file.xbm output-file.bmp" << endl ;
- exit (1) ;
- return ;
- }
-
- main (int argc, char *argv [])
- {
- if (argc != 3)
- Usage (argc, argv) ;
-
- XbmDecoder decoder ;
-
- ifstream in (argv [1]) ;
- if (! in)
- {
- cerr << "Cannot open file " << argv [1] << endl ;
- return 1 ;
- }
- BitmapImage image ;
- try
- {
- decoder.ReadImage (in, image) ;
- }
- catch (exception &ee)
- {
- cout << "-----> " << ee.what () << endl ;
- }
-
- ofstream out (argv [2], ios::binary) ;
- BmpEncoder encoder ;
- try
- {
- encoder.WriteImage (out, image) ;
- }
- catch (exception &ee)
- {
- cout << ee.what () << endl ;
- }
- return 0 ;
- }
-