From 92f003ff64717600bf1bdd545f89f38a26c9c278 Mon Sep 17 00:00:00 2001 From: Mark Lu Date: Mon, 27 Jun 2016 11:53:49 -0700 Subject: [PATCH] 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 --- docs/html/training/displaying-bitmaps/load-bitmap.jd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/html/training/displaying-bitmaps/load-bitmap.jd b/docs/html/training/displaying-bitmaps/load-bitmap.jd index f963baac3a0d9..81eb1ab58ef53 100644 --- a/docs/html/training/displaying-bitmaps/load-bitmap.jd +++ b/docs/html/training/displaying-bitmaps/load-bitmap.jd @@ -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; } }