X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctsim%2Fimagefile.cpp;h=d10e1bd8a2d9eaaeb058c526800abaaa97a93b0b;hp=356e48904e3f3e5591d285c746beb6c75b82c4be;hb=bd1d464294e037da19ccc80d8cc60475768eb2ca;hpb=f6e50ad4a0a618ebe0fc868d106745d17b53be27 diff --git a/libctsim/imagefile.cpp b/libctsim/imagefile.cpp index 356e489..d10e1bd 100644 --- a/libctsim/imagefile.cpp +++ b/libctsim/imagefile.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: imagefile.cpp,v 1.44 2001/03/30 22:09:09 kevin Exp $ +** $Id: imagefile.cpp,v 1.45 2001/09/24 09:40:42 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 @@ -46,6 +46,7 @@ const int ImageFile::EXPORT_FORMAT_PNG16 = 4; #ifdef HAVE_CTN_DICOM const int ImageFile::EXPORT_FORMAT_DICOM = 5; #endif +const int ImageFile::EXPORT_FORMAT_RAW = 6; const char* ImageFile::s_aszExportFormatName[] = { @@ -1667,6 +1668,9 @@ ImageFile::exportImage (const char* const pszFormat, const char* const pszFilena return bSuccess; } #endif + else if (iFormatID == EXPORT_FORMAT_RAW) + return writeImageRaw(pszFilename, nxcell, nycell); + sys_error (ERR_SEVERE, "Invalid format %s [ImageFile::exportImage]", pszFormat); return false; @@ -1900,3 +1904,26 @@ ImageFile::writeImageGIF (const char* const outfile, int nxcell, int nycell, dou } #endif +bool +ImageFile::writeImageRaw (const char* const outfile, int nxcell, int nycell) +{ + FILE *fp; + int nx = m_nx; + int ny = m_ny; + ImageFileArray v = getArray(); + + if ((fp = fopen (outfile, "wb")) == NULL) + return false; + + for (int irow = ny - 1; irow >= 0; irow--) { + for (int icol = 0; icol < nx; icol++) { + float dens = v[icol][irow]; + fwrite(&dens, sizeof(float), 1, fp); + } + } + + fclose(fp); + return true; +} + +