home *** CD-ROM | disk | FTP | other *** search
- #include <fstream>
- #include <time.h>
- #include "xbmencod.h"
- #include "bmpdecod.h"
-
- using namespace std ;
-
- void Usage (int argc, char *argv [])
- {
- char *program ;
- if (argc > 0)
- program = argv [0] ;
- else
- program = "DECODER" ;
-
- cerr << "Usage: " << program << " input.bmp output.xbm" << endl ;
-
- exit (1) ;
- return ;
- }
-
-
- main (int argc, char *argv [])
- {
- if (argc != 3)
- Usage (argc, argv) ;
-
- XbmEncoder encoder ;
-
- ifstream input (argv [1], ios::binary) ;
- if (! input)
- {
- cerr << "Can't open input file " << argv [1] << endl ;
- exit (1) ;
- }
-
- BmpDecoder decoder ;
- BitmapImage image ;
- try
- {
- decoder.ReadImage (input, image) ;
- }
- catch (exception &ee)
- {
- cerr << ee.what () << endl ;
- throw ;
- }
-
- ofstream output (argv [2]) ; // XBM files should not use binary mode.
- if (! output)
- {
- cerr << "Can't open output file " << argv [2] << endl ;
- exit (1) ;
- }
-
- try
- {
- encoder.WriteImage (output, image) ;
- }
- catch (exception &ee)
- {
- cerr << ee.what () << endl ;
- }
-
- return 0 ;
- }
-