Caused by: java.lang.IllegalStateException: Immutable bitmap passed to Canvas constructor

            Bitmap bmp =BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);  
            Paint paint = new Paint();
            paint.setColor(Color.BLACK);
            String str = "123";
            Canvas canvas = new Canvas(bmp);    //此句报错
            canvas.drawText(str, 0, 0, paint);

不允许直接修改res里面的图片,只要在后面加上.copy(Bitmap.Config.ARGB_8888, true);

 

修改后:

Bitmap  originalBitmap = BitmapFactory.decodeResource(getResources(),R.drawable.a).copy(Bitmap.Config.ARGB_8888, true);

 

posted @ 2015-04-13 15:37  马小豆包  阅读(5840)  评论(0编辑  收藏  举报