OSDN Git Service

Fix FP rounding error for crop bounds.
authorRuben Brunk <rubenbrunk@google.com>
Tue, 14 May 2013 07:58:37 +0000 (00:58 -0700)
committerRuben Brunk <rubenbrunk@google.com>
Tue, 14 May 2013 08:00:59 +0000 (01:00 -0700)
Bug: 8874599
Change-Id: I94198e4dcdbb0afa1dd788130645855b33e8f30b

src/com/android/gallery3d/filtershow/crop/CropMath.java

index 849ac60..671554f 100644 (file)
@@ -196,14 +196,13 @@ public class CropMath {
         float finalH = origH;
         if (origA < a) {
             finalH = origW / a;
+            r.top = r.centerY() - finalH / 2;
+            r.bottom = r.top + finalH;
         } else {
             finalW = origH * a;
+            r.left = r.centerX() - finalW / 2;
+            r.right = r.left + finalW;
         }
-        float centX = r.centerX();
-        float centY = r.centerY();
-        float hw = finalW / 2;
-        float hh = finalH / 2;
-        r.set(centX - hw, centY - hh, centX + hw, centY + hh);
     }
 
     /**