diff options
author | ByteHamster <info@bytehamster.com> | 2020-02-12 12:21:16 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2020-02-12 12:21:19 +0100 |
commit | f34430eb282eba37922a2022654e7b3eba26032f (patch) | |
tree | 32302c30a6a2f94bca777623036d30edb4abfc2c /core/src/main/java/de/danoeh/antennapod | |
parent | 25fbff6afd8bf103477a8be88c8bf114cadfb598 (diff) | |
download | AntennaPod-f34430eb282eba37922a2022654e7b3eba26032f.zip |
Increase blurred image size
Today's screens have a much better resolution than a few years ago when this code was created.
Use 1/3 of the target size of the image instead of a fixed size. The transformed image
is cached by Glide, so the transformation does not need to be done multiple times.
This way, the images look a lot better (because they are not stretched to be displayed).
Diffstat (limited to 'core/src/main/java/de/danoeh/antennapod')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/glide/FastBlurTransformation.java | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/glide/FastBlurTransformation.java b/core/src/main/java/de/danoeh/antennapod/core/glide/FastBlurTransformation.java index 3cc906b7f..d2d9e5947 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/glide/FastBlurTransformation.java +++ b/core/src/main/java/de/danoeh/antennapod/core/glide/FastBlurTransformation.java @@ -14,19 +14,15 @@ public class FastBlurTransformation extends BitmapTransformation { private static final String TAG = FastBlurTransformation.class.getSimpleName(); - private static final int STACK_BLUR_RADIUS = 1; - private static final int BLUR_IMAGE_WIDTH = 150; + private static final int STACK_BLUR_RADIUS = 5; public FastBlurTransformation() { super(); } @Override - protected Bitmap transform(BitmapPool pool, Bitmap source, - int outWidth, int outHeight) { - int targetWidth = BLUR_IMAGE_WIDTH; - int targetHeight = (int) (1.0 * outHeight * targetWidth / outWidth); - Bitmap resized = ThumbnailUtils.extractThumbnail(source, targetWidth, targetHeight); + protected Bitmap transform(BitmapPool pool, Bitmap source, int outWidth, int outHeight) { + Bitmap resized = ThumbnailUtils.extractThumbnail(source, outWidth / 3, outHeight / 3); Bitmap result = fastBlur(resized, STACK_BLUR_RADIUS); if (result == null) { Log.w(TAG, "result was null"); @@ -80,9 +76,9 @@ public class FastBlurTransformation extends BitmapTransformation { int wh = w * h; int div = radius + radius + 1; - int r[] = new int[wh]; - int g[] = new int[wh]; - int b[] = new int[wh]; + int[] r = new int[wh]; + int[] g = new int[wh]; + int[] b = new int[wh]; int rsum; int gsum; int bsum; @@ -93,11 +89,11 @@ public class FastBlurTransformation extends BitmapTransformation { int yp; int yi; int yw; - int vmin[] = new int[Math.max(w, h)]; + int[] vmin = new int[Math.max(w, h)]; int divsum = (div + 1) >> 1; divsum *= divsum; - int dv[] = new int[256 * divsum]; + int[] dv = new int[256 * divsum]; for (i = 0; i < 256 * divsum; i++) { dv[i] = (i / divsum); } @@ -225,8 +221,8 @@ public class FastBlurTransformation extends BitmapTransformation { yi = x; stackpointer = radius; for (y = 0; y < h; y++) { - // Preserve alpha channel: ( 0xff000000 & pix[yi] ) - pix[yi] = (0xff000000 & pix[yi]) | (dv[rsum] << 16) | (dv[gsum] << 8) | dv[bsum]; + // Set alpha to 1 + pix[yi] = 0xff000000 | (dv[rsum] << 16) | (dv[gsum] << 8) | dv[bsum]; rsum -= routsum; gsum -= goutsum; |