该应用程序正在崩溃此方法但未显示任何崩溃日志。这只发生在少数设备上,例如(HTC one m9),它完美地适用于HTC Desire Pro 10和Galaxy s6边缘。应用程序崩溃在script.forEach(输出);这一行。
private static Bitmap blur(Bitmap src) {
RenderScript rs = RenderScript.create(BaseApplication.getAppContext());
final Allocation input = Allocation.createFromBitmap(rs, src); //use this constructor for best performance, because it uses USAGE_SHARED mode which reuses memory
final Allocation output = Allocation.createTyped(rs, input.getType());
final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
script.setRadius(5f);
script.setInput(input);
script.forEach(output);
output.copyTo(src);
return src;
}
答案 0 :(得分:0)
我解决了这个问题,这个问题正在发生,因为我的位图配置不是Bitmap.Config.ARGB_8888,我们应该在应用模糊之前将其转换为ARGB_8888。
Bitmap U8_4Bitmap;
if (yourBitmap.getConfig() == Bitmap.Config.ARGB_8888) {
U8_4Bitmap = yourBitmap;
} else {
U8_4Bitmap = yourBitmap.copy(Bitmap.Config.ARGB_8888, true);
}