about summary refs log tree commit diff
path: root/editor
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-09-19 02:43:35 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-09-19 02:43:35 +0000
commit0be25e651de4a285c3e5777205d93ca1b9688ba9 (patch)
tree0f5db2861236ec2e12abd8c6696c80844da1be19 /editor
parent356b9a0d5450efa4d6aa249cff938ab142c48530 (diff)
downloadnetpbm-mirror-0be25e651de4a285c3e5777205d93ca1b9688ba9.tar.gz
netpbm-mirror-0be25e651de4a285c3e5777205d93ca1b9688ba9.tar.xz
netpbm-mirror-0be25e651de4a285c3e5777205d93ca1b9688ba9.zip
Fail before writing output image header when input and map maxvals don't match and an option rquired a matching maxval, i.e. -firstisdefault or -missingcolor, is specified
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3679 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor')
-rw-r--r--editor/pnmremap.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/editor/pnmremap.c b/editor/pnmremap.c
index 0038f4d7..0c0096ba 100644
--- a/editor/pnmremap.c
+++ b/editor/pnmremap.c
@@ -1043,13 +1043,6 @@ copyRaster(struct pam *   const inpamP,
     inrow  = pnm_allocpamrow(inpamP);
     outrow = pnm_allocpamrow(&workpam);
 
-    if (outpamP->maxval != inpamP->maxval && defaultColor)
-        pm_error("The maxval of the colormap (%u) is not equal to the "
-                 "maxval of the input image (%u).  This is allowable only "
-                 "if you are doing an approximate mapping (i.e. you don't "
-                 "specify -firstisdefault or -missingcolor)",
-                 (unsigned int)outpamP->maxval, (unsigned int)inpamP->maxval);
-
     selectDepthAdjustment(inpamP, outpamP->depth, &depthAdjustment);
 
     usehash = TRUE;
@@ -1120,6 +1113,13 @@ remap(FILE *             const ifP,
         outpam.width  = inpam.width;
         outpam.height = inpam.height;
 
+        if (outpam.maxval != inpam.maxval && defaultColor)
+            pm_error("The maxval of the colormap (%u) is not equal to the "
+                     "maxval of the input image (%u).  This is allowable only "
+                     "if you are doing an approximate mapping (i.e. you don't "
+                     "specify -firstisdefault or -missingcolor)",
+                     (unsigned int)outpam.maxval, (unsigned int)inpam.maxval);
+
         pnm_writepaminit(&outpam);
 
         /* Set up so input buffers have extra space as needed to