about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-08-18 02:06:21 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-08-18 02:06:21 +0000
commitb2e350036b3d3e65d9d130f2eafbd06b2f69f34d (patch)
treed52d8265d0fbce631ad61755bc5df43235ca98d6
parentaa4918c06812130152727da1e35822635f99e8ea (diff)
downloadnetpbm-mirror-b2e350036b3d3e65d9d130f2eafbd06b2f69f34d.tar.gz
netpbm-mirror-b2e350036b3d3e65d9d130f2eafbd06b2f69f34d.tar.xz
netpbm-mirror-b2e350036b3d3e65d9d130f2eafbd06b2f69f34d.zip
Fix bogus depth calculation for non-visual PAM input
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4414 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--editor/pamcat.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/editor/pamcat.c b/editor/pamcat.c
index a2b2ef41..f44062c5 100644
--- a/editor/pamcat.c
+++ b/editor/pamcat.c
@@ -354,14 +354,15 @@ computeOutputParms(unsigned int       const fileCt,
         if (inpamP->tuple_type != firstTupletype)
             allSameTt = false;
 
-        if (!inpamP->visual)
-            allVisual = false;
+        if (inpamP->visual) {
+            maxColorDepth = MAX(maxColorDepth, inpamP->color_depth);
 
-        if (inpamP->have_opacity)
-            haveOpacity = true;
+            if (inpamP->have_opacity)
+                haveOpacity = true;
+        } else
+            allVisual = false;
 
         maxDepth      = MAX(maxDepth,      inpamP->depth);
-        maxColorDepth = MAX(maxColorDepth, inpamP->color_depth);
         maxMaxval     = MAX(maxMaxval,     inpamP->maxval);
 
         if (PAM_FORMAT_TYPE(inpamP->format) > PAM_FORMAT_TYPE(newFormat))
@@ -370,7 +371,6 @@ computeOutputParms(unsigned int       const fileCt,
     assert(newCols       > 0);
     assert(newRows       > 0);
     assert(maxMaxval     > 0);
-    assert(maxColorDepth > 0);
     assert(newFormat     > 0);
 
     if (newCols > INT_MAX)
@@ -387,8 +387,11 @@ computeOutputParms(unsigned int       const fileCt,
     */
     outpamP->height           = (unsigned int)newRows;
     outpamP->width            = (unsigned int)newCols;
-    outpamP->depth            = MAX(maxDepth,
+    if (allVisual)
+        outpamP->depth        = MAX(maxDepth,
                                     maxColorDepth + (haveOpacity ? 1 : 0));
+    else
+        outpamP->depth        = maxDepth;
     outpamP->allocation_depth = 0;  /* This means same as depth */
     outpamP->maxval           = maxMaxval;
     outpamP->format           = newFormat;