** This is part of the CTSim program
** Copyright (c) 1983-2001 Kevin Rosenberg
**
-** $Id: imagefile.cpp,v 1.43 2001/03/28 16:53:43 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
#ifdef HAVE_CTN_DICOM
const int ImageFile::EXPORT_FORMAT_DICOM = 5;
#endif
+const int ImageFile::EXPORT_FORMAT_RAW = 6;
const char* ImageFile::s_aszExportFormatName[] =
{
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;
png_init_io(png_ptr, fp);
- png_set_IHDR (png_ptr, info_ptr, nx * nxcell, ny * nycell, bitdepth, PNG_COLOR_TYPE_GRAY, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_DEFAULT);
+ png_set_IHDR (png_ptr, info_ptr, nx * nxcell, ny * nycell, bitdepth, PNG_COLOR_TYPE_GRAY, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
png_write_info(png_ptr, info_ptr);
for (int irow = ny - 1; irow >= 0; irow--) {
}
#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;
+}
+
+