about summary refs log tree commit diff
path: root/converter/other/pnmtopng.c
diff options
context:
space:
mode:
Diffstat (limited to 'converter/other/pnmtopng.c')
-rw-r--r--converter/other/pnmtopng.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/converter/other/pnmtopng.c b/converter/other/pnmtopng.c
index ac171453..ce723d40 100644
--- a/converter/other/pnmtopng.c
+++ b/converter/other/pnmtopng.c
@@ -2436,7 +2436,11 @@ doIhdrChunk(struct pngx * const pngxP,
             unsigned int  const depth,
             bool          const colorMapped,
             bool          const colorPng,
-            bool          const alpha) {
+            bool          const alpha,
+            bool          const interlace) {
+
+    int const interlaceMethod =
+        interlace ? PNG_INTERLACE_ADAM7 : PNG_INTERLACE_NONE;
 
     int colorType;
 
@@ -2450,7 +2454,8 @@ doIhdrChunk(struct pngx * const pngxP,
     if (alpha && colorType != PNG_COLOR_TYPE_PALETTE)
         colorType |= PNG_COLOR_MASK_ALPHA;
 
-    pngx_setIhdr(pngxP, width, height, depth, colorType, 0, 0, 0);
+    pngx_setIhdr(pngxP, width, height, depth, colorType,
+                 interlaceMethod, 0, 0);
 }
 
 
@@ -2820,10 +2825,8 @@ convertpnm(struct cmdlineInfo const cmdline,
         pm_error ("setjmp returns error condition (2)");
     }
 
-    doIhdrChunk(pngxP, cols, rows, depth, colorMapped, colorPng, alpha);
-
-    if (cmdline.interlace)
-        pngx_setInterlaceHandling(pngxP);
+    doIhdrChunk(pngxP, cols, rows, depth, colorMapped, colorPng, alpha,
+                cmdline.interlace);
 
     doGamaChunk(cmdline, pngxP);
 
@@ -2875,6 +2878,8 @@ convertpnm(struct cmdlineInfo const cmdline,
     /* let libpng take care of, e.g., bit-depth conversions */
     pngx_setPacking(pngxP);
 
+    pngx_setInterlaceHandling(pngxP);
+
     writeRaster(pngxP, ifP, rasterPos,
                 cols, rows, maxval, format,
                 pngMaxval, depth, alpha, alpha_mask, cht, caht);