codelab-android-workmanager icon indicating copy to clipboard operation
codelab-android-workmanager copied to clipboard

RenderScript was deprecate

Open frolix opened this issue 2 years ago • 1 comments

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

frolix avatar Apr 12 '23 08:04 frolix

Instructions say: "Add the library to your Android Studio project by modifying the app's build.gradle file."

Modify how? Add a dependency? What should it say?

Joe-Zap avatar Sep 18 '23 11:09 Joe-Zap