X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=libctsim%2Fimagefile.cpp;h=20946ae77ae25b4d99c51f19c2e63642709d13ea;hb=17769327fd2f5f84a867532c04864864e23f4238;hp=3f7c0beff717a84bafe3f588816dfc50d29bf0db;hpb=a5139613f6b92aeb8db9daa87f021c78d17d82a5;p=ctsim.git diff --git a/libctsim/imagefile.cpp b/libctsim/imagefile.cpp index 3f7c0be..20946ae 100644 --- a/libctsim/imagefile.cpp +++ b/libctsim/imagefile.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (C) 1983-2000 Kevin Rosenberg ** -** $Id: imagefile.cpp,v 1.10 2000/08/22 16:49:56 kevin Exp $ +** $Id: imagefile.cpp,v 1.14 2000/11/22 07:17:06 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 @@ -66,7 +66,7 @@ ImageFile::displayScaling (const int scale, const ImageFileValue pmin, const Ima return 0; #if HAVE_G2_H - int pens [nx * ny * scale * scale ]; + int* pPens = new int [nx * ny * scale * scale ]; double view_scale = 255 / (pmax - pmin); int id_X11 = g2_open_X11 (nx * scale, ny * scale); @@ -76,21 +76,26 @@ ImageFile::displayScaling (const int scale, const ImageFileValue pmin, const Ima grayscale[i] = g2_ink (id_X11, cval, cval, cval); } - for (int i= 0, iy = ny - 1; iy >= 0; iy--) { - for (int ix = 0; ix < nx; ix++) { - int cval = static_cast((v[ix][iy] - pmin) * view_scale); - if (cval < 0) - cval = 0; - else if (cval > 255) - cval = 255; - pens[i++] = grayscale[cval]; + for (int iy = ny - 1; iy >= 0; iy--) { + int iRowPos = ((ny - 1 - iy) * scale) * (nx * scale); + for (int ix = 0; ix < nx; ix++) { + int cval = static_cast((v[ix][iy] - pmin) * view_scale); + if (cval < 0) + cval = 0; + else if (cval > 255) + cval = 255; + for (int sy = 0; sy < scale; sy++) + for (int sx = 0; sx < scale; sx++) + pPens[iRowPos+(sy * nx * scale)+(sx + (ix * scale))] = grayscale[cval]; } } - g2_image (id_X11, 0., 0., nx, ny, pens); + g2_image (id_X11, 0., 0., nx * scale, ny * scale, pPens); + delete pPens; return (id_X11); - +#else + return 0; #endif } @@ -313,7 +318,7 @@ ImageFile::writeImagePGM (const char *outfile, int nxcell, int nycell, double de } for (int ir = 0; ir < nycell; ir++) { for (int ic = 0; ic < nx * nxcell; ic++) - fprintf(fp, "%c ", rowp[ic]); + fprintf(fp, "%c", rowp[ic]); } } @@ -329,8 +334,6 @@ ImageFile::writeImagePGMASCII (const char *outfile, int nxcell, int nycell, doub ImageFileArray v = getArray(); unsigned char rowp [nx * nxcell]; - if (rowp == NULL) - return; if ((fp = fopen (outfile, "wb")) == NULL) return;