From 0be25e651de4a285c3e5777205d93ca1b9688ba9 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Thu, 19 Sep 2019 02:43:35 +0000 Subject: 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 --- editor/pnmremap.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'editor') 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 -- cgit 1.4.1