X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=src%2Fif2img.cpp;h=1aa8a39d49bf44c04520cbabcec0cbff1332bbf8;hb=a8ba12a8c971de1d8cb3ef1c3a7d2d9fcf45affa;hp=c3a4bfe801ab80d56c42cd8afc4055db9faaaaec;hpb=207332eec9416d299766abb697312cfd27eb890e;p=ctsim.git diff --git a/src/if2img.cpp b/src/if2img.cpp index c3a4bfe..1aa8a39 100644 --- a/src/if2img.cpp +++ b/src/if2img.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: if2img.cpp,v 1.7 2000/06/19 17:58:13 kevin Exp $ +** $Id: if2img.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 @@ -279,30 +279,15 @@ if2img_main (int argc, char *const argv[]) out_file = argv[optind+1]; else out_file = NULL; - pim = new ImageFile (in_file); + pim = new ImageFile (); ImageFile& im = *pim; - if (! im.fileRead()) { + if (! im.fileRead(in_file)) { sys_error (ERR_FATAL, "File %s does not exist", in_file); return (1); } - if (opt_labels) { - int nlabels = im.getNumLabels(); - - for (int i = 0; i < nlabels; i++) { - Array2dFileLabel label; - im.labelRead (label, i); - - if (label.getLabelType() == Array2dFileLabel::L_HISTORY) { - cout << "History: " << label.getLabelString() << endl; - cout << " calc time = " << label.getCalcTime() << " secs" << endl; - cout << " Timestamp = " << label.getDateString() << endl; - } else if (label.getLabelType() == Array2dFileLabel::L_USER) { - cout << "Note: " << label.getLabelString() << endl; - cout << " Timestamp = %s" << label.getDateString() << endl; - } - } - } + if (opt_labels) + im.printLabels(cout); if (opt_stats || (! (opt_set_max && opt_set_min))) { double minfound = HUGE_VAL, maxfound = -HUGE_VAL; @@ -451,7 +436,7 @@ sdf2d_to_pgm (ImageFile& im, char *outfile, int nxcell, int nycell, double densm int ny = im.ny(); ImageFileArray v = im.getArray(); - unsigned char* rowp = new unsigned char [nx * nxcell]; + unsigned char rowp [nx * nxcell]; if ((fp = fopen (outfile, "wb")) == NULL) return; @@ -474,7 +459,6 @@ sdf2d_to_pgm (ImageFile& im, char *outfile, int nxcell, int nycell, double densm fprintf(fp, "%c ", rowp[ic]); } } - delete rowp; fclose(fp); } @@ -487,7 +471,7 @@ sdf2d_to_pgmasc (ImageFile& im, char *outfile, int nxcell, int nycell, double de int ny = im.ny(); ImageFileArray v = im.getArray(); - unsigned char* rowp = new unsigned char [nx * nxcell]; + unsigned char rowp [nx * nxcell]; if (rowp == NULL) return; @@ -513,7 +497,6 @@ sdf2d_to_pgmasc (ImageFile& im, char *outfile, int nxcell, int nycell, double de fprintf(fp, "\n"); } } - delete rowp; fclose(fp); } @@ -531,7 +514,7 @@ sdf2d_to_png (ImageFile& im, char *outfile, int bitdepth, int nxcell, int nycell int ny = im.ny(); ImageFileArray v = im.getArray(); - unsigned char* rowp = new unsigned char [nx * nxcell * (bitdepth / 8)]; + unsigned char rowp [nx * nxcell * (bitdepth / 8)]; if ((fp = fopen (outfile, "wb")) == NULL) return; @@ -580,7 +563,6 @@ sdf2d_to_png (ImageFile& im, char *outfile, int bitdepth, int nxcell, int nycell for (int ir = 0; ir < nycell; ir++) png_write_rows (png_ptr, &row_pointer, 1); } - delete rowp; png_write_end(png_ptr, info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr); @@ -605,7 +587,7 @@ sdf2d_to_gif (ImageFile& im, char *outfile, int nxcell, int nycell, double densm int ny = im.ny(); ImageFileArray v = im.getArray(); - usnigned char* rowp = new unsigned char [nx * nxcell]; + unsigned char rowp [nx * nxcell]; if (rowp == NULL) return; @@ -628,7 +610,6 @@ sdf2d_to_gif (ImageFile& im, char *outfile, int nxcell, int nycell, double densm } } } - delete rowp; if ((out = fopen(outfile,"w")) == NULL) { sys_error(ERR_FATAL, "Error opening output file %s for writing", outfile);