Hi, I got the error NegativeArraySizeException as soon as
PImage imgCell9 = imgSource.get(288, 0, cellWidth, cellHeight); // Assign
gets uncommented, I can't get futher then 8 for some stange reason since it should give a problem when it gets higher then 64.
Here's the image i use:
Code:PImage imgSource;
PImage[] imgCell; // Declare
int cellWidth = 32;
int cellHeight = 32;
int cells; //total ammount of cells
int rows, columns;
void setup(){
size(500, 500);
imgSource = loadImage("test.png");
columns = imgSource.width/cellWidth;
rows = imgSource.height/cellHeight;
cells = rows*columns;
imgCell = new PImage[cells]; // Create
noLoop();
}
void draw(){
PImage imgCell0 = imgSource.get(0, 0, cellWidth, cellHeight); // Assign
PImage imgCell1 = imgSource.get(32, 0, cellWidth, cellHeight); // Assign
PImage imgCell2 = imgSource.get(64, 0, cellWidth, cellHeight); // Assign
PImage imgCell3 = imgSource.get(96, 0, cellWidth, cellHeight); // Assign
PImage imgCell4 = imgSource.get(128, 0, cellWidth, cellHeight); // Assign
PImage imgCell5 = imgSource.get(160, 0, cellWidth, cellHeight); // Assign
PImage imgCell6 = imgSource.get(192, 0, cellWidth, cellHeight); // Assign
PImage imgCell7 = imgSource.get(224, 0, cellWidth, cellHeight); // Assign
PImage imgCell8 = imgSource.get(256, 0, cellWidth, cellHeight); // Assign
/* PImage imgCell9 = imgSource.get(288, 0, cellWidth, cellHeight); // Assign
PImage imgCell10 = imgSource.get(320, 0, cellWidth, cellHeight); // Assign
PImage imgCell11 = imgSource.get(352, 0, cellWidth, cellHeight); // Assign
PImage imgCell12 = imgSource.get(384, 0, cellWidth, cellHeight); // Assign
PImage imgCell13 = imgSource.get(416, 0, cellWidth, cellHeight); // Assign
*/
image(imgCell0, 0, 0);
image(imgCell1, 32, 0);
image(imgCell2, 64, 0);
image(imgCell3, 96, 0);
image(imgCell4, 128, 0);
image(imgCell5, 160, 0);
image(imgCell6, 192, 0);
image(imgCell7, 224, 0);
image(imgCell8, 256, 0);
/* image(imgCell9, 288, 0);
image(imgCell10, 320, 0);
image(imgCell11, 352, 0);
image(imgCell12, 384, 0);
image(imgCell13, 416, 0);
*/
}