X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctsim%2Fimagefile.cpp;h=9df4285a8a35904ee88939647bb6a5428f81a51b;hp=3f7c0beff717a84bafe3f588816dfc50d29bf0db;hb=1e88cf0f7fa4f690ea9f110e8ed3f2b5338d0a10;hpb=74a34e63a9a356e1467acdba65497ab15190dde0 diff --git a/libctsim/imagefile.cpp b/libctsim/imagefile.cpp index 3f7c0be..9df4285 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.11 2000/08/25 15:59:13 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,19 +76,23 @@ 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); #endif