trying to use a recycled bitmap android.graphics.Bitmap
异常:trying to use a recycled bitmap android.graphics.Bitmap
概意:试图使用已经recycled的Bitmap
一般情况下我们在对Bitmap进行Matrix的各种缩放、平移等处理,然后createBitmap,再对之前的Bitmap进行recycle处理。
例如:
Bitmap oldBitmap= BitmapFactory.decodeFile(pathName);
Matrix matrix = new Matrix();
matrix.setScale(0.5f, 0.5f);
Bitmap newBitmap= Bitmap.createBitmap(bitmapDecode, 0, 0,
oldBitmap.getWidth(), oldBitmap.getHeight(), matrix, true);
if(!oldBitmap.isRecycled()){oldBitmap.recycle();
}
异常的根本问题出在“Bitmap.createBitmap”函数这里:
/*** Returns an immutable bitmap from subset of the source bitmap,* transformed by the optional matrix. The new bitmap may be the* same object as source, or a copy may have been made. It is* initialized with the same density as the original bitmap.* * If the source bitmap is immutable
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
