android using Renderscript for blur effect crashes causes A/libc: Fatal signal 7 (SIGBUS), code 2, fault addr 0x9e6fa000 in tid 482 (AsyncTask #1)

匿名 (未验证) 提交于 2019-12-03 00:46:02

问题:

I use blur effect,while applying to bitmap loaded from resources it works as expected,while using universal-imageloader to download image and applying to bitmap it causes A/libc: Fatal signal 7 (SIGBUS), code 2, fault addr 0x9d56e000 in tid 31955 (AsyncTask #1)

public class MyActivity extends ActionBarActivity { private ImageView ivBackground;  @Override protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.activity_my);     ivBackground = (ImageView) findViewById(R.id.iv_background);     String imageUri = "https://upload.wikimedia.org/wikipedia/commons/c/c2/Macau-bus-1032.jpg";     ImageLoader imageLoader = ImageLoader.getInstance();     imageLoader.init(ImageLoaderConfiguration.createDefault(this));     DisplayImageOptions options = new DisplayImageOptions.Builder()             .showImageForEmptyUri(Color.TRANSPARENT)             .showImageOnFail(Color.TRANSPARENT)             .resetViewBeforeLoading(true)             .cacheOnDisk(true)             .cacheInMemory(false)             .bitmapConfig(Bitmap.Config.RGB_565)             .considerExifParams(true)             .displayer(new FadeInBitmapDisplayer(300))             .build();      imageLoader.displayImage(imageUri, ivBackground, options, new SimpleImageLoadingListener() {           @Override         public void onLoadingComplete(final String imageUri, View view, final Bitmap loadedImage) { Bitmap bmpTest = BitmapFactory.decodeResource(getResources(), R.drawable.test); //final Bitmap cropedBitmap = Bitmap.createBitmap(bmpTest, 0, 0, bmpTest.getWidth() / 2, bmpTest.getHeight()); final Bitmap cropedBitmap = Bitmap.createBitmap(loadedImage, 0, 0, loadedImage.getWidth() / 2, loadedImage.getHeight());              ivBackground.setImageBitmap(cropedBitmap);             new AsyncTask<Void, Void, Bitmap>() {                 @Override                 protected Bitmap doInBackground(Void... params) { Bitmap bitmap = ((BitmapDrawable) ivBackground.getDrawable()).getBitmap();             return blurBitmap(bitmap);                 }                  @Override                 protected void onPostExecute(Bitmap aVoid) {                     ivBackground.setImageBitmap(aVoid);                 }             }.execute();         }          @Override         public void onLoadingCancelled(String imageUri, View view) {          }     }); } private Bitmap blurBitmap(Bitmap bitmap) {     Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);      RenderScript rs = RenderScript.create(MyActivity.this);     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; } 

}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!