我终于找到了一个合适的解决方案:
但是,关于ScriptIntrinsicBlur
该类的文档非常少见,我花了更多时间来找出正确的调用参数。为了模糊一个名为 的普通ARGB_8888
类型位图photo
,这里它们是:
final RenderScript rs = RenderScript.create( myAndroidContext );
final Allocation input = Allocation.createFromBitmap( rs, photo, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT );
final Allocation output = Allocation.createTyped( rs, input.getType() );
final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create( rs, Element.U8_4( rs ) );
script.setRadius( myBlurRadius /* e.g. 3.f */ );
script.setInput( input );
script.forEach( output );
output.copyTo( photo );