+ for (int i = 0; i < s_iFormatCount; i++)\r
+ if (strcasecmp (formatName, s_aszFormatName[i]) == 0) {\r
+ formatID = i;\r
+ break;\r
+ }\r
+\r
+ return (formatID);\r
+}\r
+\r
+const char*\r
+ImageFile::convertFormatIDToName (int formatID)\r
+{\r
+ static const char *formatName = "";\r
+\r
+ if (formatID >= 0 && formatID < s_iFormatCount)\r
+ return (s_aszFormatName[formatID]);\r
+\r
+ return (formatName);\r
+}\r
+\r
+const char*\r
+ImageFile::convertFormatIDToTitle (const int formatID)\r
+{\r
+ static const char *formatTitle = "";\r
+\r
+ if (formatID >= 0 && formatID < s_iFormatCount)\r
+ return (s_aszFormatTitle[formatID]);\r
+\r
+ return (formatTitle);\r
+}\r
+\r
+bool\r
+ImageFile::exportImage (const char* const pszFormat, const char* const pszFilename, int nxcell, int nycell, double densmin, double densmax)\r
+{\r
+ int iFormatID = convertFormatNameToID (pszFormat);\r
+ if (iFormatID == FORMAT_INVALID) {\r
+ sys_error (ERR_SEVERE, "Invalid format %s [ImageFile::exportImage]", pszFormat);\r
+ return false;\r
+ }\r
+\r
+ if (iFormatID == FORMAT_PGM)\r
+ return writeImagePGM (pszFilename, nxcell, nycell, densmin, densmax);\r
+ else if (iFormatID == FORMAT_PGMASCII)\r
+ return writeImagePGMASCII (pszFilename, nxcell, nycell, densmin, densmax);\r
+ else if (iFormatID == FORMAT_PNG)\r
+ return writeImagePNG (pszFilename, 8, nxcell, nycell, densmin, densmax);\r
+ else if (iFormatID == FORMAT_PNG16)\r
+ return writeImagePNG (pszFilename, 16, nxcell, nycell, densmin, densmax);\r
+\r
+ sys_error (ERR_SEVERE, "Invalid format %s [ImageFile::exportImage]", pszFormat);\r
+ return false;\r
+}\r
+\r
+bool
+ImageFile::writeImagePGM (const char* const outfile, int nxcell, int nycell, double densmin, double densmax)