我终于找到一个合适的解决方案:
但是,关于ScriptIntrinsicBlur
类的文档非常少见,我花了一些时间来计算正确的调用参数。对于bluring名为photo
普通ARGB_8888
-typed位图,在这里,他们是:
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);
@ thV0ID:很好的答案。有什么办法可以使它向后兼容,也可以在ICS中工作? – 2013-07-13 07:03:29
@BhaveshPatadiya:您可以使用RenderScript实现快速卷积并使用高斯内核。在RenderScript中实现卷积的一个例子可以在这里找到:http://stackoverflow.com/a/10257994/1444073 – theV0ID 2013-07-31 19:39:05
RS现在是兼容性库的一部分,renderscript-v8.jar – Gabor 2013-09-24 15:44:23