Skip to content

RenderScript was deprecate #318

@frolix

Description

@frolix

In WorkerUtils.kt fun blurBitmap
Change code

rsContext = RenderScript.create(applicationContext, RenderScript.ContextType.DEBUG)
       val inAlloc = Allocation.createFromBitmap(rsContext, bitmap)
       val outAlloc = Allocation.createTyped(rsContext, inAlloc.type)
       val theIntrinsic = ScriptIntrinsicBlur.create(rsContext, Element.U8_4(rsContext))
       theIntrinsic.apply {
           setRadius(10f)
           theIntrinsic.setInput(inAlloc)
           theIntrinsic.forEach(outAlloc)
       }
       outAlloc.copyTo(output)

to

var blurredBitmap: Bitmap? = Toolkit.blur(bitmap,25)
 return blurredBitmap!!

Instruction to migrate
https://developer.android.com/guide/topics/renderscript/migrate

You just need to download the project, get the renderscript-toolkit module and add it to this Codelab project.
https://github.com/android/renderscript-intrinsics-replacement-toolkit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions