OSDN Git Service

Fix downsampling check in crop.
authorRuben Brunk <rubenbrunk@google.com>
Thu, 11 Apr 2013 00:27:33 +0000 (17:27 -0700)
committerRuben Brunk <rubenbrunk@google.com>
Thu, 11 Apr 2013 00:27:33 +0000 (17:27 -0700)
Bug: 8586301
Change-Id: I4c5441f779122adb984368609cfea39a60190848

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

index d2a681f..132d6c1 100644 (file)
@@ -144,14 +144,16 @@ public abstract class CropLoader {
 
             // Find best downsampling size
             int imageSide = Math.max(w, h);
+            options.inSampleSize = 1;
             if (imageSide > maxSideLength) {
                 int shifts = 1 + Integer.numberOfLeadingZeros(maxSideLength)
                         - Integer.numberOfLeadingZeros(imageSide);
-                options.inSampleSize = 1 << shifts;
+                options.inSampleSize <<= shifts;
             }
 
             // Make sure sample size is reasonable
-            if (0 >= (int) (Math.min(w, h) / options.inSampleSize)) {
+            if (options.inSampleSize <= 0 ||
+                    0 >= (int) (Math.min(w, h) / options.inSampleSize)) {
                 return null;
             }