我需要将模糊效果应用于通过universal-imageloader
下载的位图
但崩溃和日志中我得到了这样的信息:
// 4508-4564 / com.sample A / libc:致命信号7(SIGBUS),代码2,故障地址0x9c4e9000 in tid 4564(com.sample) // 07-18 19:49:20.019 4508-4570 / com.sample A / libc:致命信号7(SIGBUS),代码2,故障地址0x9c4e9000 in tid 4570(com.sample) // 07-18 19:49:20.019 4508-4569 / com.sample A / libc:致命信号7(SIGBUS),代码2,故障地址0x9c4e9000 in tid 4569(com.sample) // 07-18 19:49:20.019 4508-4565 / com.sample A / libc:致命信号7(SIGBUS),代码2,故障地址0x9c4e9000 in tid 4565(com.sample)
ImageLoader imageLoader = ImageLoaderInstances.initGeneralImageLoader();
imageLoader.loadImage(fileName,new SimpleImageLoadingListener(){
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
cropedBitmap = Bitmap.createBitmap(loadedImage, 0, 0, loadedImage.getWidth() / 2, loadedImage.getHeight());
imageView.setImageBitmap(blurBitmap(cropedBitmap));
}
});
private Bitmap blurBitmap(Bitmap bitmap) {
Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
RenderScript rs = RenderScript.create(getContext());
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
Allocation allIn = Allocation.createFromBitmap(rs, bitmap);
Allocation allOut = Allocation.createFromBitmap(rs, outBitmap);
blurScript.setRadius(25.f);
blurScript.setInput(allIn);
blurScript.forEach(allOut);
allOut.copyTo(outBitmap);
bitmap.recycle();
rs.destroy();
return outBitmap;
}
答案 0 :(得分:0)
添加一些日志记录来验证,或者使用调试器,但我认为崩溃很可能发生在这一行:
output.copyTo(blurredBitmap);
创建blurredBitmap
时,输入位图的宽度和高度的1/10。它的Allocation
是输入位图的完整大小。