about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2008-07-16 02:33:30 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2008-07-16 02:33:30 +0000
commit7dc7e15eea1409f028459bfee76eb02e54f0ec98 (patch)
tree090c282e06c3e17383ff3e485c8f9cadec3d0e37
parentb7ec37261845b154531e53ad0af7f597f47c86fc (diff)
downloadnetpbm-mirror-7dc7e15eea1409f028459bfee76eb02e54f0ec98.tar.gz
netpbm-mirror-7dc7e15eea1409f028459bfee76eb02e54f0ec98.tar.xz
netpbm-mirror-7dc7e15eea1409f028459bfee76eb02e54f0ec98.zip
Fix bug: garbage output from PBMs
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@677 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY5
-rw-r--r--editor/pamflip.c23
2 files changed, 17 insertions, 11 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index 629fdc0e..47add239 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -20,6 +20,11 @@ not yet  BJH  Release 10.44.00
               Add pbmminkowski (source code has been in package since 10.12
               but not documented or built by default).
 
+              pamflip: fix bug: garbage output for PBMs, since 10.42.
+
+              pngtopnm: fix bug: when background is color, output
+              should be PPM.
+
 08.06.27 BJH  Release 10.43.00
 
               Add pamtompfont: Mplayer bitmap font.
diff --git a/editor/pamflip.c b/editor/pamflip.c
index e47daf36..87f57809 100644
--- a/editor/pamflip.c
+++ b/editor/pamflip.c
@@ -443,8 +443,9 @@ transformRowByRowPbm(struct pam * const inpamP,
                      struct pam * const outpamP,
                      bool         const reverse) {
 /*----------------------------------------------------------------------------
-  Transform a PBM image either by flipping it left for right, or just leaving
-  it alone, as indicated by 'reverse'.
+  Transform a PBM raster either by flipping it left for right, or just
+  leaving it alone, as indicated by 'reverse'.  Read the raster from
+  *inpamP; write the transformed raster to *outpamP.
 
   Process the image one row at a time and use fast packed PBM bit
   reverse algorithm (where required).
@@ -454,8 +455,6 @@ transformRowByRowPbm(struct pam * const inpamP,
 
     bitrow = pbm_allocrow_packed(outpamP->width); 
 
-    pbm_writepbminit(outpamP->file, outpamP->width, outpamP->height, 0);
-
     for (row = 0; row < inpamP->height; ++row) {
         pbm_readpbmrow_packed(inpamP->file,  bitrow, inpamP->width,
                               inpamP->format);
@@ -475,7 +474,8 @@ transformRowByRowNonPbm(struct pam * const inpamP,
                         struct pam * const outpamP,
                         bool         const reverse) {
 /*----------------------------------------------------------------------------
-  Flip an image left for right or leave it alone.
+  Flip a raster left for right or leave it alone.  Read the raster
+  from *inpamP; write the transformed raster to *outpamP.
 
   Process one row at a time.
 
@@ -526,7 +526,8 @@ transformRowsBottomTopPbm(struct pam * const inpamP,
                           struct pam * const outpamP,
                           bool         const reverse) { 
 /*----------------------------------------------------------------------------
-  Flip a PBM image top for bottom.
+  Flip a PBM raster top for bottom; read the raster from *inpamP;
+  write the flipped raster to *outpamP.
 
   Read complete image into memory in packed PBM format; Use fast
   packed PBM bit reverse algorithm (where required).
@@ -534,7 +535,7 @@ transformRowsBottomTopPbm(struct pam * const inpamP,
     unsigned int const rows=inpamP->height;
 
     unsigned char ** bitrow;
-    int row;
+    unsigned int row;
         
     bitrow = pbm_allocarray_packed(outpamP->width, outpamP->height);
         
@@ -542,8 +543,6 @@ transformRowsBottomTopPbm(struct pam * const inpamP,
         pbm_readpbmrow_packed(inpamP->file, bitrow[row], 
                               inpamP->width, inpamP->format);
 
-    pbm_writepbminit(outpamP->file, outpamP->width, outpamP->height, 0);
-
     for (row = 0; row < rows; ++row) {
         if (reverse) 
             bitOrderReverse(bitrow[rows-row-1], inpamP->width);
@@ -560,7 +559,8 @@ static void
 transformRowsBottomTopNonPbm(struct pam * const inpamP, 
                              struct pam * const outpamP) {
 /*----------------------------------------------------------------------------
-  Do a simple vertical flip.
+  Do a simple vertical flip.  Read the raster from *inpamP; write the
+  flipped raster to *outpamP.
 
   We do this faster than the more general subroutines because we just
   move the row pointers.
@@ -677,7 +677,6 @@ transformPbmGen(struct pam *     const inpamP,
          }
     }
     
-    pbm_writepbminit(outpamP->file, outpamP->width, outpamP->height, 0);
     for (row = 0; row < outpamP->height; ++row)
         pbm_writepbmrow_packed(outpamP->file, newbits[row], outpamP->width, 0);
     
@@ -696,6 +695,8 @@ transformNonPbmWhole(struct pam *     const inpamP,
   Do the transform using "pam" library functions, as opposed to "pbm"
   ones.
 
+  Read the raster from *inpamP; write the transformed raster to *outpamP.
+
   Assume input file is positioned to the raster (just after the
   header).