我正在从事涉及位图操作的项目。因为我不想出现 OutofMemoryError,所以我尝试回收每个未使用的位图。不幸的是,我回收了太多并且出现了“尝试使用回收的位图”错误。
我在用:
Bitmap.createBitmap(bmp, x,y,w,h, matrix, false);
Bitmap.createScaledBitmap(bmp, w, h,true);
我应该在这个方法之后回收 bmp 还是由它们回收?喜欢:
Bitmap newBitmap = Bitmap.createBitmap(bmp, x,y,w,h, matrix, false);
bmp.recycle();
我可以在 imageView.setImageBitmap() 之后回收之前在这里使用过的吗?例如。
myImageView.setImageBitmap(myBitmap);
myImageView.setImageBitmap(newBitmap);
myBitmap.recycle();
谢谢你的帮助。