Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 41185c4f authored by Ruben Brunk's avatar Ruben Brunk
Browse files

Fix downsampling check in crop.

Bug: 8586301
Change-Id: I4c5441f779122adb984368609cfea39a60190848
parent 27b9459f
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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;
            }