美文网首页
Caused by: java.lang.IllegalStat

Caused by: java.lang.IllegalStat

作者: Android小白菜 | 来源:发表于2018-01-16 10:08 被阅读0次

    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);

    相关文章

      网友评论

          本文标题:Caused by: java.lang.IllegalStat

          本文链接:https://www.haomeiwen.com/subject/nizjoxtx.html