createBitmap — java.lang.IllegalArgumentException: x must be < bitmap.width()错误的解决

秒速五厘米 2022-07-16 10:45 210阅读 0赞

No, not x must be < bitmap.width(). It says x + width must be <= bitmap.width().

You are creating a Bitmap like so:

  1. Bitmap.createBitmap(source, 60, 0, 480, 260); // 320 - 60 = 260

Basically, you are drawing from x = 60, y = 0 to x = 480 + 60, y = 260 on a Bitmap which is only 480x320. Obviously, this is not possible, since your x coordinate is off the Bitmap.

It’s hard to tell you how to fix this without knowing your exact use case. Basically, your sourceimage has to fit within { x1: x, x2: x + width, y1: y, y2: y + height }.

原文

发表评论

表情:
评论列表 (有 0 条评论,210人围观)

还没有评论,来说两句吧...

相关阅读