我終於找到一個合適的解決方案:
但是,關於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