Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 988b7865 authored by Kshitij's avatar Kshitij
Browse files

fix: De-jank blurring on DPI change

- Calling createBitmap with just width and height completely disregards the
  density of input bitmap.
- We can just copy input bitmap and overwrite that to save us the trouble
parent 54c92bcb
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -180,21 +180,17 @@ class BlurWallpaperProvider(val context: Context) {
    }

    private fun applyVibrancy(wallpaper: Bitmap): Bitmap {
        val width = wallpaper.width
        val height = wallpaper.height

        val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
        val canvas = Canvas()
        canvas.setBitmap(bitmap)
        mVibrancyPaint.colorFilter =
            ColorMatrixColorFilter(ColorMatrix().apply { setSaturation(1.25f) })

        val colorMatrix = ColorMatrix()
        colorMatrix.setSaturation(1.25f)
        val filter = ColorMatrixColorFilter(colorMatrix)
        mVibrancyPaint.colorFilter = filter
        canvas.drawBitmap(wallpaper, 0f, 0f, mVibrancyPaint)
        val bitmap = Bitmap.createBitmap(wallpaper)
        Canvas().apply {
            setBitmap(bitmap)
            drawBitmap(wallpaper, 0f, 0f, mVibrancyPaint)
        }

        wallpaper.recycle()

        return bitmap
    }