Android IllegalArgumentException: Cannot draw recycled bitmaps解决方法
在编码图集过程中,出现了Android IllegalArgumentException: Cannot draw recycled bitmaps错误。
大致意思是:不能使用已经被回收的bitmap。
bitmap回收部分代码如下:
1 Bitmap removeBitmap = softReference.get();  
2 if(removeBitmap != null && !removeBitmap.isRecycled()){  
3     removeBitmap.recycle();
4     removeBitmap = null;  
5 } 
解决方法:
重写ImageView中的OnDraw方法,捕获此异常。
 1 public class MyImageView extends ImageView {  
 2   
 3     public MyImageView (Context context, AttributeSet attrs) {  
 4         super(context, attrs);  
 5     }  
 6   
 7     @Override  
 8     protected void onDraw(Canvas canvas) {  
 9         try {  
10             super.onDraw(canvas);  
11         } catch (Exception e) {  
12             System.out.println("trying to use a recycled bitmap");  
13         }  
14     }  
    ---------------------------------------------------------------------------------
笔者水平有限,若有错漏,欢迎指正,如果转载以及CV操作,请务必注明出处,谢谢!
笔者水平有限,若有错漏,欢迎指正,如果转载以及CV操作,请务必注明出处,谢谢!
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号