about summary refs log tree commit diff
path: root/editor
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-02-10 02:56:44 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-02-10 02:56:44 +0000
commitc26aa6fd9d6d42418310c9fca3e8344e83f35c5a (patch)
treef61d5e522f2dff51bb3c6cdd30518e649683da7a /editor
parent95a66834f2c7775836e8d66f3b1da176438cf94b (diff)
downloadnetpbm-mirror-c26aa6fd9d6d42418310c9fca3e8344e83f35c5a.tar.gz
netpbm-mirror-c26aa6fd9d6d42418310c9fca3e8344e83f35c5a.tar.xz
netpbm-mirror-c26aa6fd9d6d42418310c9fca3e8344e83f35c5a.zip
speed up
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1122 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor')
-rw-r--r--editor/pamflip.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/editor/pamflip.c b/editor/pamflip.c
index 61c6efce..83f776af 100644
--- a/editor/pamflip.c
+++ b/editor/pamflip.c
@@ -656,28 +656,44 @@ transformPbmGen(struct pam *     const inpamP,
             
     computeXformMatrix(&xform, inpamP->width, inpamP->height, xformCore);
     
-    bitrow = pbm_allocrow(inpamP->width);
-    newbits = pbm_allocarray(pbm_packed_bytes(outpamP->width), 
-                             outpamP->height);
+    bitrow = pbm_allocrow_packed(inpamP->width);
+    newbits = pbm_allocarray_packed( outpamP->width, outpamP->height );
             
     /* Initialize entire array to zeroes.  One bits will be or'ed in later */
     for (row = 0; row < outpamP->height; ++row) {
         unsigned int col;
         for (col = 0; col < pbm_packed_bytes(outpamP->width); ++col) 
-             newbits[row][col] = 0; 
+            newbits[row][col] = 0; 
     }
     
     for (row = 0; row < inpamP->height; ++row) {
         unsigned int col;
-        pbm_readpbmrow(inpamP->file, bitrow, inpamP->width, inpamP->format);
-        for (col = 0; col < inpamP->width; ++col) {
-            unsigned int newcol, newrow;
-            transformPoint(col, row, xform, &newcol, &newrow);
-            newbits[newrow][newcol/8] |= bitrow[col] << (7 - newcol % 8);
-                /* Use of "|=" patterned after pbm_readpbmrow_packed. */
-         }
+
+        pbm_readpbmrow_packed(inpamP->file, bitrow,
+                              inpamP->width, inpamP->format);
+        for (col = 0; col < inpamP->width; ) {
+            if (bitrow[col/8] == 0x00) 
+                col += 8;  /* Blank.   Skip to next byte. */
+            else {      /* Examine each pixel. */
+                unsigned int const colLimit = MIN(col+8, inpamP->width);
+                unsigned int i;
+
+                for (i = 0; col < colLimit; ++i, ++col) {
+                    bool const bitIsOne = (bitrow[col/8] >> (7-i)) & 0x01;
+                    if (bitIsOne) {
+                        /* Write in only the one bits. */  
+                        unsigned int newcol, newrow;
+                        transformPoint(col, row, xform, &newcol, &newrow);
+                        newbits[newrow][newcol/8] |= 0x01 << (7 - newcol % 8);
+                            /* Use of "|=" patterned after
+                               pbm_readpbmrow_packed().
+                            */
+                    }
+                }
+            }
+        }
     }
-    
+
     for (row = 0; row < outpamP->height; ++row)
         pbm_writepbmrow_packed(outpamP->file, newbits[row], outpamP->width, 0);