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

Commit 3e361da4 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Ensure Bitmap.Config.ARGB_8888 before blurring

RenderScript needs this Bitmap format, otherwise channels will be mixed up

Bug: 124466617
Test: visual
Change-Id: Ib7e436d0e8f2d81b3f3c1b58c4e6052b194ec8e4
parent c47e6f61
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -51,8 +51,15 @@ class MediaArtworkProcessor @Inject constructor() {
        val renderScript = RenderScript.create(context)
        val rect = Rect(0, 0, artwork.width, artwork.height)
        MathUtils.fitRect(rect, Math.max(mTmpSize.x / DOWNSAMPLE, mTmpSize.y / DOWNSAMPLE))
        val inBitmap = Bitmap.createScaledBitmap(artwork, rect.width(), rect.height(),
        var inBitmap = Bitmap.createScaledBitmap(artwork, rect.width(), rect.height(),
                true /* filter */)
        // Render script blurs only support ARGB_8888, we need a conversion if we got a
        // different bitmap config.
        if (inBitmap.config != Bitmap.Config.ARGB_8888) {
            val oldIn = inBitmap
            inBitmap = oldIn.copy(Bitmap.Config.ARGB_8888, false /* isMutable */)
            oldIn.recycle()
        }
        val input = Allocation.createFromBitmap(renderScript, inBitmap,
                Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_GRAPHICS_TEXTURE)
        val outBitmap = Bitmap.createBitmap(inBitmap.width, inBitmap.height,