about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2011-03-05 04:17:44 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2011-03-05 04:17:44 +0000
commitc78a59617e67e216540d2f934c573ad5d22356a2 (patch)
tree12138e57c24b67042f126b80dc657089eaa2d92f
parent6f4c455716dfc4ba61ae4e72a09b33874e9142cf (diff)
downloadnetpbm-mirror-c78a59617e67e216540d2f934c573ad5d22356a2.tar.gz
netpbm-mirror-c78a59617e67e216540d2f934c573ad5d22356a2.tar.xz
netpbm-mirror-c78a59617e67e216540d2f934c573ad5d22356a2.zip
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1421 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--editor/pamrubber.c75
1 files changed, 44 insertions, 31 deletions
diff --git a/editor/pamrubber.c b/editor/pamrubber.c
index 9ee88a56..fa31c50b 100644
--- a/editor/pamrubber.c
+++ b/editor/pamrubber.c
@@ -1173,6 +1173,44 @@ createWhiteTuple(const struct pam * const pamP,
 
 
 
+static sample
+pix(tuple **     const rdTuples,
+    point        const p,
+    unsigned int const plane,
+    bool         const linear) {
+                    
+    double pix;
+
+    if (!linear) {
+        pix = rdTuples
+            [(int) floor(p.y + 0.5)]
+            [(int) floor(p.x + 0.5)][plane];
+    } else {
+        double const rx = p.x - floor(p.x);
+        double const ry = p.y - floor(p.y);
+        pix = 0.0;
+        pix += (1.0 - rx) * (1.0 - ry)
+            * rdTuples
+            [(int) floor(p.y)]
+            [(int) floor(p.x)][plane];
+        pix += rx * (1.0 - ry)
+            * rdTuples
+            [(int) floor(p.y)]
+            [(int) floor(p.x) + 1][plane];
+        pix += (1.0 - rx) * ry 
+            * rdTuples
+            [(int) floor(p.y) + 1]
+            [(int) floor(p.x)][plane];
+        pix += rx * ry
+            * rdTuples
+            [(int) floor(p.y) + 1]
+            [(int) floor(p.x) + 1][plane];
+    }
+    return (int) floor(pix);
+}
+
+
+
 int
 main(int argc, const char ** const argv) {
 
@@ -1233,37 +1271,12 @@ main(int argc, const char ** const argv) {
             p1.y += 1E-3;
             if ((p1.x >= 0.0) && (p1.x < (double) inpam.width - 0.5) &&
                 (p1.y >= 0.0) && (p1.y < (double) inpam.height - 0.5)) {
-                unsigned int i;
-                for (i = 0; i < inpam.depth; ++i) {
-                    double pix;
-
-                    if (!cmdline.linear) {
-                        pix = rdTuples
-                            [(int) floor(p1.y + 0.5)]
-                            [(int) floor(p1.x + 0.5)][i];
-                    } else {
-                        double const rx = p1.x - floor(p1.x);
-                        double const ry = p1.y - floor(p1.y);
-                        pix = 0.0;
-                        pix += (1.0 - rx) * (1.0 - ry)
-                            * rdTuples
-                            [(int) floor(p1.y)]
-                            [(int) floor(p1.x)][i];
-                        pix += rx * (1.0 - ry)
-                            * rdTuples
-                            [(int) floor(p1.y)]
-                            [(int) floor(p1.x) + 1][i];
-                        pix += (1.0 - rx) * ry 
-                            * rdTuples
-                            [(int) floor(p1.y) + 1]
-                            [(int) floor(p1.x)][i];
-                        pix += rx * ry
-                            * rdTuples
-                            [(int) floor(p1.y) + 1]
-                            [(int) floor(p1.x) + 1][i];
-                    }
-                    wrTuples[p2y][p2x][i] = floor(pix);
-                } /* end for */
+                unsigned int plane;
+                for (plane = 0; plane < inpam.depth; ++plane) {
+                    wrTuples[p2y][p2x][plane] =
+                        pix(rdTuples, p1, plane, cmdline.linear);
+
+                }
             }
         }
     }