回收再利用后的位图变 [英] Reusing the bitmap variable after recycle

查看:152
本文介绍了回收再利用后的位图变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经回收了位图的变量,当我试图再次使用相同的变量,我有一些奇怪的错误,参照回收。任何解决这个问题?

的Java code:

image1.recycle(); 此搜索= NULL;

LogCat中:

  11月五号至29日:35:42.139:E / AndroidRuntime(695):java.lang.RuntimeException的:画布:试图用一个循环位图android.graphics.Bitmap@2bbad018
十一月5号至29号:35:42.139:E / AndroidRuntime(695):在android.graphics.Canvas.throwIfRecycled(Canvas.java:1038)
十一月5号至29号:35:42.139:E / AndroidRuntime(695):在android.graphics.Canvas.drawBitmap(Canvas.java:1078)
 

解决方案

在你回收的内存被释放的位图。这是否意味着位图数据从内存中消失了。如果你想再次使用相同的变量,你必须去$ C C的位图againg $。

 如果(此搜索== NULL || image1.isRecycled()){
    此搜索= BitmapFactory.de codeStream()
}
 

I have recycled the bitmap variable and when I again tried to use the same variable I have some strange errors with reference to recycle. Any solution to this issue ?

java code:

image1.recycle(); image1=null;

LogCat:

05-29 11:35:42.139: E/AndroidRuntime(695): java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@2bbad018
05-29 11:35:42.139: E/AndroidRuntime(695):  at android.graphics.Canvas.throwIfRecycled(Canvas.java:1038)
05-29 11:35:42.139: E/AndroidRuntime(695):  at android.graphics.Canvas.drawBitmap(Canvas.java:1078)

解决方案

Once you recycle the bitmap its memory is freed. That's mean that bitmaps data are gone from the memory. If you want to use again the same variable you have to decode the Bitmap againg .

if (image1 == null || image1.isRecycled()) {
    image1 = BitmapFactory.decodeStream()
}

这篇关于回收再利用后的位图变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆