Problem splitting an image into several pieces
in
Programming Questions
•
10 months ago
Hi,
I am trying to split an image previously loaded into four different ones to be able to move them freely in the screen, but when I try to assign the pixels values of the original image to the new created one, I get an error saying "ArrayIndexOutOfBoundsException", here is the piece of code:
.......
imagen.loadPixels();
trozo[0].loadPixels();
for(y=0;y<trozo[0].height;y++)
for(x=0;x<trozo[0].width;x++){
loc=x+y*trozo[0].width;
trozo[0].pixels[loc]=imagen.pixels[loc]; //copio pixels
}
trozo[0].updatePixels();
.......
Image is the original image, while trozo[0] is the first piece I want to create, Can anyone please help?
Thanks and brgds,
1