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

Commit 411f7190 authored by Kshitij's avatar Kshitij
Browse files

fix!: Copy bitmap before applying to canvas

- Not doing so yields an empty line at the bottom of the blur view
- Copying the bitmap with a defined config ensures no crashes on
  emulator and older devices - makes bitmap mutable and non-hardware
parent 6b764275
Loading
Loading
Loading
Loading
+13 −7
Original line number Original line Diff line number Diff line
@@ -184,14 +184,20 @@ class BlurWallpaperProvider(val context: Context) {
        mVibrancyPaint.colorFilter =
        mVibrancyPaint.colorFilter =
            ColorMatrixColorFilter(ColorMatrix().apply { setSaturation(1.25f) })
            ColorMatrixColorFilter(ColorMatrix().apply { setSaturation(1.25f) })


        val bitmap =
        val origBitmap = Bitmap.createBitmap(wallpaper)
            Bitmap.createBitmap(
        val bitmap = origBitmap.copy(Bitmap.Config.ARGB_8888, true)
        Canvas().apply {
            try {
                setBitmap(bitmap)
            } catch (e: IllegalStateException) {
                Logger.e(TAG, "Failed to set bitmap, using fallback", e)
                val newBitmap = Bitmap.createBitmap(
                    wallpaper.width,
                    wallpaper.width,
                    wallpaper.height,
                    wallpaper.height,
                    wallpaper.config ?: Bitmap.Config.ARGB_8888
                    wallpaper.config ?: Bitmap.Config.ARGB_8888
                )
                )
        Canvas().apply {
                setBitmap(newBitmap)
            setBitmap(bitmap)
            }
            drawBitmap(wallpaper, 0f, 0f, mVibrancyPaint)
            drawBitmap(wallpaper, 0f, 0f, mVibrancyPaint)
        }
        }