【发布时间】:2011-03-08 16:13:05
【问题描述】:
谁能告诉我为什么在拆分位图时会出现此错误。 代码:
public static List<Bitmap> ScambleImage(Bitmap image, int rows, int cols){
List<Bitmap> scambledImage = new ArrayList<Bitmap>();
int chunkWidth = image.getWidth(); //cols
int chunkHeight = image.getHeight(); //rows
int finalSize = chunkWidth/rows;
Bitmap bMapScaled = Bitmap.createScaledBitmap(image, chunkWidth, chunkHeight, true);
int yCoord = 0;//The y coordinate of the first pixel in source
for(int x = 0; x < rows; x++){
int xCoord = 0;//The x coordinate of the first pixel in source
for(int y = 0; y < cols; y++){
scambledImage.add(Bitmap.createBitmap(bMapScaled, xCoord, yCoord, finalSize, finalSize));
xCoord = finalSize + xCoord;
}
yCoord = finalSize + yCoord;//The y coordinate of the first pixel in source
}
return scambledImage;
}
行 = 6,列 = 6; 图像尺寸 = 648 x 484
这是例外,但不知道如何解决:
java.lang.IllegalArgumentException: y + height must be <= bitmap.height()
谢谢!
【问题讨论】:
标签: android bitmap android-image