diff --git a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/TransformationUtils.java b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/TransformationUtils.java index e17e7500cea90a3e7814ae9a9c62ae733ce39f2a..c81ad355484dfc6cfd7871b869625110417708bc 100644 --- a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/TransformationUtils.java +++ b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/TransformationUtils.java @@ -127,11 +127,10 @@ public final class TransformationUtils { final float heightPercentage = height / (float) inBitmap.getHeight(); final float minPercentage = Math.min(widthPercentage, heightPercentage); - // take the floor of the target width/height, not round. If the matrix - // passed into drawBitmap rounds differently, we want to slightly - // overdraw, not underdraw, to avoid artifacts from bitmap reuse. - final int targetWidth = (int) (minPercentage * inBitmap.getWidth()); - final int targetHeight = (int) (minPercentage * inBitmap.getHeight()); + // Round here in case we've decoded exactly the image we want, but take the floor below to + // avoid a line of garbage or blank pixels in images. + int targetWidth = Math.round(minPercentage * inBitmap.getWidth()); + int targetHeight = Math.round(minPercentage * inBitmap.getHeight()); if (inBitmap.getWidth() == targetWidth && inBitmap.getHeight() == targetHeight) { if (Log.isLoggable(TAG, Log.VERBOSE)) { @@ -140,6 +139,12 @@ public final class TransformationUtils { return inBitmap; } + // Take the floor of the target width/height, not round. If the matrix + // passed into drawBitmap rounds differently, we want to slightly + // overdraw, not underdraw, to avoid artifacts from bitmap reuse. + targetWidth = (int) (minPercentage * inBitmap.getWidth()); + targetHeight = (int) (minPercentage * inBitmap.getHeight()); + Bitmap.Config config = getSafeConfig(inBitmap); Bitmap toReuse = pool.get(targetWidth, targetHeight, config);