我尝试使用该方法创建缩放位图,但是一旦我访问位图,我的应用程序崩溃并显示以下消息:
"java.lang.IllegalArgumentException: y + height must be <= bitmap.height()"
当我调试它时,我可以在调用“createScaledBitmap”后立即看到,生成的位图的大小为-1,-1。如果我改为使用“createBitmap”,结果位图会显示原始位图的大小。
如果没有人知道这是什么原因...是否可能有一种解决方法来调整位图的大小不同?我在位图类中找不到任何东西,但也许有人知道另一种方式吗?
答案 0 :(得分:0)
首先,我想澄清一下您是从Bitmap.createBitmap方法获取错误,而不是从Bitmap.createScaledBitmap。 createBitmap的语法如下所示,
Bitmap.createBitmap(位图源,int x,int y,int width,int height,Matrix m,boolean filter)
Parameters
source: The bitmap we are subsetting
x: The x coordinate of the first pixel in source
y: The y coordinate of the first pixel in source
width: The number of pixels in each row
height: The number of rows
m: Optional matrix to be applied to the pixels
filter: true if the source should be filtered. Only applies if the matrix contains more than just translation.
发生错误,
x,y,width,height值超出了源位图的尺寸。