about summary refs log tree commit diff
path: root/converter/ppm/ppmtogif.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-11-14 16:50:28 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-11-14 16:50:28 +0000
commit611cda2e1a36d5d38b497a756e59b447396fbeca (patch)
treeb36439212343a9d8b39ce8e2e93a2dbf9dfc1e35 /converter/ppm/ppmtogif.c
parent4678fc5692c3cd9745f567ab35643a0b24ded670 (diff)
downloadnetpbm-mirror-611cda2e1a36d5d38b497a756e59b447396fbeca.tar.gz
netpbm-mirror-611cda2e1a36d5d38b497a756e59b447396fbeca.tar.xz
netpbm-mirror-611cda2e1a36d5d38b497a756e59b447396fbeca.zip
Fix garbage output from ppmtogif -interlace
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@131 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/ppm/ppmtogif.c')
-rw-r--r--converter/ppm/ppmtogif.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/converter/ppm/ppmtogif.c b/converter/ppm/ppmtogif.c
index 9521237b..9522042a 100644
--- a/converter/ppm/ppmtogif.c
+++ b/converter/ppm/ppmtogif.c
@@ -370,7 +370,16 @@ ppm_seek(FILE *             const fileP,
          pixval             const maxval,
          unsigned int       const col,
          unsigned int       const row) {
+/*----------------------------------------------------------------------------
+   Seek to Row 'row', Column 'col' of the raster of the PPM image on
+   file *fileP.
 
+   Assume the image has 'cols' columns and maxval 'maxval' and that
+   its raster begins at file position *rasterPosP.  'rasterPosSize' is
+   how many bytes wide *rasterPosP is, since Caller may have a different
+   idea of type pm_filepos than we have.
+-----------------------------------------------------------------------------*/
+    unsigned int const depth = 3;  /* PPM has 3 samples per pixel */
     pm_filepos rasterPos;
     pm_filepos pixelPos;
 
@@ -383,7 +392,7 @@ ppm_seek(FILE *             const fileP,
                  "Valid sizes are %u and %u", 
                  rasterPosSize, sizeof(pm_filepos), sizeof(long));
 
-    pixelPos = rasterPos + row * cols * bytesPerSample(maxval) + col;
+    pixelPos = rasterPos + row * cols * depth * bytesPerSample(maxval) + col;
 
     pm_seek2(fileP, &pixelPos, sizeof(pixelPos));
 }
@@ -451,8 +460,8 @@ pixelReaderGotoNextInterlaceRow(pixelReader * const rdrP) {
             break;
         }
     }
-    /* Now that we know which row should be current, get its
-       pixels into the buffer.
+    /* Now that we know which row should be current, position the file
+       there (so that the next ppm_readppmrow() reads that row).
     */
     ppm_seek(rdrP->fileP, &rdrP->rasterPos, sizeof(rdrP->rasterPos),
              rdrP->width, rdrP->maxval, 0, rdrP->next.row);