about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2007-05-24 00:08:51 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2007-05-24 00:08:51 +0000
commit46e4d7d33bf46cd4e81c6cf7aa2333d36283b82b (patch)
tree8af28ac3111d3f8d7ae27d07c5b6e25a64938f45
parent6e4a9488d1b7c1598be0498d703c94e148aefc96 (diff)
downloadnetpbm-mirror-46e4d7d33bf46cd4e81c6cf7aa2333d36283b82b.tar.gz
netpbm-mirror-46e4d7d33bf46cd4e81c6cf7aa2333d36283b82b.tar.xz
netpbm-mirror-46e4d7d33bf46cd4e81c6cf7aa2333d36283b82b.zip
Add -omaxval
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@312 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--converter/other/fitstopnm.c60
-rw-r--r--doc/HISTORY14
2 files changed, 48 insertions, 26 deletions
diff --git a/converter/other/fitstopnm.c b/converter/other/fitstopnm.c
index 9e6e1830..86bdfbb8 100644
--- a/converter/other/fitstopnm.c
+++ b/converter/other/fitstopnm.c
@@ -54,6 +54,8 @@ struct cmdlineInfo {
            -plain now.  (pnm_init() processes -plain).
         */
     unsigned int verbose;
+    unsigned int omaxval;
+    unsigned int omaxvalSpec;
 };
 
 
@@ -81,20 +83,22 @@ parseCommandLine(int argc, char ** argv,
     MALLOCARRAY_NOFAIL(option_def, 100);
 
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0, "image",   OPT_UINT,
-            &cmdlineP->image,  &imageSpec,                            0);
-    OPTENT3(0, "min",     OPT_FLOAT,
-            &cmdlineP->min,    &cmdlineP->minSpec,                    0);
-    OPTENT3(0, "max",     OPT_FLOAT,
-            &cmdlineP->max,    &cmdlineP->maxSpec,                    0);
-    OPTENT3(0, "scanmax", OPT_FLAG,
-            NULL,              &cmdlineP->scanmax,                    0);
+    OPTENT3(0, "image",    OPT_UINT,
+            &cmdlineP->image,   &imageSpec,                            0);
+    OPTENT3(0, "min",      OPT_FLOAT,
+            &cmdlineP->min,     &cmdlineP->minSpec,                    0);
+    OPTENT3(0, "max",      OPT_FLOAT,
+            &cmdlineP->max,     &cmdlineP->maxSpec,                    0);
+    OPTENT3(0, "scanmax",  OPT_FLAG,
+            NULL,               &cmdlineP->scanmax,                    0);
     OPTENT3(0, "printmax", OPT_FLAG,
-            NULL,              &cmdlineP->printmax,                   0);
+            NULL,               &cmdlineP->printmax,                   0);
     OPTENT3(0, "noraw",    OPT_FLAG,
-            NULL,              &cmdlineP->noraw,                      0);
+            NULL,               &cmdlineP->noraw,                      0);
     OPTENT3(0, "verbose",  OPT_FLAG,
-            NULL,              &cmdlineP->verbose,                    0);
+            NULL,               &cmdlineP->verbose,                    0);
+    OPTENT3(0, "omaxval",  OPT_UINT,
+            &cmdlineP->omaxval, &cmdlineP->omaxvalSpec,                0);
 
     opt.opt_table = option_def;
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
@@ -463,17 +467,29 @@ determineMaxval(struct cmdlineInfo const cmdline,
 
     xelval retval;
                 
-    if (fitsHeader.bitpix < 0) {
-        /* samples are floating point, which means the resolution could be
-           anything.  So we just pick a convenient maxval of 255.  We should
-           have a program option to choose the maxval.  Before Netpbm 10.20
-           (January 2004), we did maxval = max - min for floating point as
-           well as integer samples.
-        */
-        retval = 255;
-    } else
-        retval = MAX(1, MIN(PNM_OVERALLMAXVAL, datamax - datamin));
-
+    if (cmdline.omaxvalSpec)
+        retval = cmdline.omaxval;
+    else {
+        if (fitsHeader.bitpix < 0) {
+            /* samples are floating point, which means the resolution
+               could be anything.  So we just pick a convenient maxval
+               of 255.  Before Netpbm 10.20 (January 2004), we did
+               maxval = max - min for floating point as well as
+               integer samples.
+            */
+            retval = 255;
+            if (cmdline.verbose)
+                pm_message("FITS image has floating point samples.  "
+                           "Using maxval = %u.", (unsigned int)retval);
+        } else {
+            retval = MAX(1, MIN(PNM_OVERALLMAXVAL, datamax - datamin));
+            if (cmdline.verbose)
+                pm_message("FITS image has samples in the range %d-%d.  "
+                           "Using maxval %u.",
+                           (int)(datamin+0.5), (int)(datamax+0.5),
+                           (unsigned int)retval);
+        }
+    }
     return retval;
 }
 
diff --git a/doc/HISTORY b/doc/HISTORY
index f3c2aabf..ff07e167 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -6,10 +6,7 @@ CHANGE HISTORY
 
 not yet  BJH  Release 10.39.00
 
-              PAM_STRUCT_SIZE: cast pointer to ulong instead of uint.
-
-              pamthreshold: fix totally bogus threshold selection with
-              simple thresholding.
+              fitstopnm: add -omaxval.
 
               pnmremap: add -norand.
 
@@ -17,6 +14,15 @@ not yet  BJH  Release 10.39.00
 
               pbmtext: improve error messages about fonts.
 
+              pamtofits: fix -min, -max.
+
+              fitstopnm: fix BITPIX = -32.
+
+              PAM_STRUCT_SIZE: cast pointer to ulong instead of uint.
+
+              pamthreshold: fix totally bogus threshold selection with
+              simple thresholding.
+
               Configure: do test compile for missing Libxml2 and too old
               Libxml2.