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

Commit 92f003ff authored by Mark Lu's avatar Mark Lu
Browse files

docs: Fixed logic for determining image sample size

The code sample in the "Load a Scaled Down Version into Memory"
section on the "Loading Large Bitmaps Efficiently" page now handles
corner cases correctly when determining how to downscale an image by
a factor that is equal to a power of 2.

Bug: 25944661
Change-Id: I971f90fb5d153abec4bc1d96ae465e3910e82efa
parent b2cd9c95
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -115,8 +115,8 @@ public static int calculateInSampleSize(

        // Calculate the largest inSampleSize value that is a power of 2 and keeps both
        // height and width larger than the requested height and width.
        while ((halfHeight / inSampleSize) > reqHeight
                && (halfWidth / inSampleSize) > reqWidth) {
        while ((halfHeight / inSampleSize) >= reqHeight
                && (halfWidth / inSampleSize) >= reqWidth) {
            inSampleSize *= 2;
        }
    }