Chinaunix首页 | 论坛 | 博客
  • 博客访问: 867971
  • 博文数量: 182
  • 博客积分: 1992
  • 博客等级: 上尉
  • 技术积分: 1766
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-18 11:49
文章分类

全部博文(182)

文章存档

2019年(1)

2016年(5)

2015年(29)

2014年(38)

2013年(21)

2012年(36)

2011年(52)

我的朋友

分类: Android平台

2013-09-17 11:42:00

http://blog.csdn.net/lquanshui/article/details/8235824
java.lang.IllegalArgumentException: Cannot draw recycled bitmapsat android.view.GLES20Canvas.drawBitmap(GLES20Canvas.java:778)at android.view.GLES20RecordingCanvas.drawBitmap(GLES20RecordingCanvas.java:117)at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:393)at android.widget.ImageView.onDraw(ImageView.java:979)at android.view.View.draw(View.java:13458)at android.view.View.getDisplayList(View.java:12409)at android.view.View.getDisplayList(View.java:12453)at android.view.View.draw(View.java:13182)at android.view.ViewGroup.drawChild(ViewGroup.java:2929)at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)at android.view.View.draw(View.java:13461)at android.view.View.getDisplayList(View.java:12409)at android.view.View.getDisplayList(View.java:12453)at android.view.View.draw(View.java:13182)at android.view.ViewGroup.drawChild(ViewGroup.java:2929)at android.widget.ListView.drawChild(ListView.java:3226)at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2799)at android.widget.AbsListView.dispatchDraw(AbsListView.java:2433)at android.widget.ListView.dispatchDraw(ListView.java:3221)at android.view.View.draw(View.java:13461)at android.widget.AbsListView.draw(AbsListView.java:3759)

经分析,引起原因:

android4.0android4.1api差异,Bitmap在创建缩略图时,4.1.1的时候,若缩略图和原图大小一样,创建的缩略图会返回原图,若原图的bitmap人为的回收或者系统回收,就会引起此异常。

GLES20Canvas相关源码如下:

android 4.0

    public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) {
        // Shaders are ignored when drawing bitmaps
        int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE;
        final int nativePaint = paint == null ? 0 : paint.mNativePaint;
        nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, left, top, nativePaint);
        if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers);
    }

android4.1

    public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) {
        if (bitmap.isRecycled()) throw new IllegalArgumentException("Cannot draw recycled bitmaps");

        // Shaders are ignored when drawing bitmaps
        int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE;
        try {
            final int nativePaint = paint == null ? 0 : paint.mNativePaint;
            nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, left, top, nativePaint);
        } finally {
            if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers);
        }
    }

因此,需要在以前写的程序中,加入异常捕获,程序才运行正常。

阅读(5436) | 评论(0) | 转发(0) |
0

上一篇:EditText隐藏键盘

下一篇:hide keyboard

给主人留下些什么吧!~~