From a2f9ffa363dd1cd0f3ffc98ff14b678ed249b3a2 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Sun, 3 Nov 2024 15:13:49 +0100 Subject: [PATCH] Always top-align blurred image (#7484) --- .../antennapod/ui/glide/FastBlurTransformation.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ui/glide/src/main/java/de/danoeh/antennapod/ui/glide/FastBlurTransformation.java b/ui/glide/src/main/java/de/danoeh/antennapod/ui/glide/FastBlurTransformation.java index 54040e4b4..43e8f99db 100644 --- a/ui/glide/src/main/java/de/danoeh/antennapod/ui/glide/FastBlurTransformation.java +++ b/ui/glide/src/main/java/de/danoeh/antennapod/ui/glide/FastBlurTransformation.java @@ -1,7 +1,9 @@ package de.danoeh.antennapod.ui.glide; import android.graphics.Bitmap; -import android.media.ThumbnailUtils; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Rect; import androidx.annotation.NonNull; import android.util.Log; @@ -27,9 +29,13 @@ public class FastBlurTransformation extends BitmapTransformation { @NonNull Bitmap source, int outWidth, int outHeight) { - int targetWidth = outWidth / 3; + int targetWidth = outWidth / 2; int targetHeight = (int) (1.0 * outHeight * targetWidth / outWidth); - Bitmap resized = ThumbnailUtils.extractThumbnail(source, targetWidth, targetHeight); + Bitmap resized = Bitmap.createBitmap(targetWidth, targetHeight, Bitmap.Config.ARGB_8888); + Canvas c = new Canvas(resized); + c.drawBitmap(source, + new Rect(0, 0, source.getWidth(), source.getHeight()), + new Rect(0, 0, targetWidth, targetWidth * source.getWidth() / source.getHeight()), new Paint()); Bitmap result = fastBlur(resized, STACK_BLUR_RADIUS); if (result == null) { Log.w(TAG, "result was null");