X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=sidebyside;f=src%2Fif-1.cpp;h=b1d352bb5e994a43a3eb315719fc0a841a535613;hb=2f3d6e2580db607105bb072b13e4aff453ae4495;hp=3150cf9e6044c9a94a8f09f5b4bb19915b17647e;hpb=031437896d0dc6cac70c16e5604b10f5aa4d0767;p=ctsim.git diff --git a/src/if-1.cpp b/src/if-1.cpp index 3150cf9..b1d352b 100644 --- a/src/if-1.cpp +++ b/src/if-1.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: if-1.cpp,v 1.6 2000/06/13 16:20:31 kevin Exp $ +** $Id: if-1.cpp,v 1.9 2000/06/26 21:15:24 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -49,17 +49,17 @@ static struct option my_options[] = void if1_usage (const char *program) { - fprintf(stdout, "if1_usage: %s infile outfile [OPTIONS]\n", fileBasename(program)); - fprintf(stdout, "Generate a IF file from a IF file\n"); - fprintf(stdout, "\n"); - fprintf(stdout, " --invert Invert image\n"); - fprintf(stdout, " --log Natural logrithm of image\n"); - fprintf(stdout, " --exp Natural exponential of image\n"); - fprintf(stdout, " --sqr Square of image\n"); - fprintf(stdout, " --sqrt Square root of image\n"); - fprintf(stdout, " --verbose Verbose modem\n"); - fprintf(stdout, " --version Print version\n"); - fprintf(stdout, " --help Print this help message\n"); + cout << "usage: " << fileBasename(program) << " infile outfile [OPTIONS]" << endl; + cout << "Generate a IF file from a IF file" << endl; + cout << endl; + cout << " --invert Invert image" << endl; + cout << " --log Natural logrithm of image" << endl; + cout << " --exp Natural exponential of image" << endl; + cout << " --sqr Square of image" << endl; + cout << " --sqrt Square root of image" << endl; + cout << " --verbose Verbose modem" << endl; + cout << " --version Print version" << endl; + cout << " --help Print this help message" << endl; } int @@ -105,11 +105,11 @@ if1_main (int argc, char *const argv[]) break; case O_VERSION: #ifdef VERSION - fprintf(stdout, "Version %s\n", VERSION); + cout << "Version " << VERSION << endl; #else - fprintf(stderr, "Unknown version number"); + cout << "Unknown version number" << endl; #endif - exit(0); + return (0); case O_HELP: case '?': if1_usage(argv[0]); @@ -135,12 +135,11 @@ if1_main (int argc, char *const argv[]) if (opt_invert || opt_log || opt_exp || opt_sqr || opt_sqrt) { int ix, iy; - im_in = new ImageFile (in_file); - im_in->fileRead (); + im_in = new ImageFile (); + im_in->fileRead (in_file); int nx = im_in->nx(); int ny = im_in->ny(); - im_out = new ImageFile (out_file, nx, ny); - im_out->fileCreate (); + im_out = new ImageFile (nx, ny); ImageFileArray vIn = im_in->getArray(); ImageFileArray vOut = im_out->getArray(); @@ -176,10 +175,9 @@ if1_main (int argc, char *const argv[]) histString = "Sqrt transformation"; } - im_out->arrayDataWrite (); im_out->labelsCopy (*im_in); im_out->labelAdd (Array2dFileLabel::L_HISTORY, histString.c_str()); - im_out->fileClose (); + im_out->fileWrite (out_file); } return (0); @@ -189,7 +187,17 @@ if1_main (int argc, char *const argv[]) int main (int argc, char *const argv[]) { - return (if1_main(argc, argv)); + int retval = 1; + + try { + retval = if1_main(argc, argv); + } catch (exception e) { + cerr << "Exception: " << e.what() << endl; + } catch (...) { + cerr << "Unknown exception" << endl; + } + + return (retval); } #endif