diff --git a/app/src/main/java/xyz/cottongin/radio247/ui/util/BlurTransformation.kt b/app/src/main/java/xyz/cottongin/radio247/ui/util/BlurTransformation.kt index 85966a4..865584d 100644 --- a/app/src/main/java/xyz/cottongin/radio247/ui/util/BlurTransformation.kt +++ b/app/src/main/java/xyz/cottongin/radio247/ui/util/BlurTransformation.kt @@ -29,11 +29,15 @@ class BlurTransformation( private suspend fun Bitmap.stackBlur(scale: Float, radius: Int): Bitmap? = withContext(Dispatchers.IO) { var sentBitmap = this@stackBlur - val width = (sentBitmap.width * scale).roundToInt() - val height = (sentBitmap.height * scale).roundToInt() + val width = (sentBitmap.width * scale).roundToInt().coerceAtLeast(1) + val height = (sentBitmap.height * scale).roundToInt().coerceAtLeast(1) sentBitmap = Bitmap.createScaledBitmap(sentBitmap, width, height, false) val bitmap = sentBitmap.copy(sentBitmap.config ?: Bitmap.Config.ARGB_8888, true) - if (radius < 1) return@withContext null + if (radius < 1) { + sentBitmap.recycle() + bitmap.recycle() + return@withContext null + } val w = bitmap.width val h = bitmap.height val pix = IntArray(w * h)