Hi,
I´m quite new in processing and trying to crop multiple images in a defined grid and arrange them in a array.
So pictures 0 has to be croped in cell 1, picture two in cell 1 and so on and so on
Until now I didnt found a possibility to crop the pictures. Does anyone know a solution for this?
So far I managed to load 4 images inside, named 0,1,2,3.jpeg and arrange them in a grid.
Thanks in advance
I´m quite new in processing and trying to crop multiple images in a defined grid and arrange them in a array.
So pictures 0 has to be croped in cell 1, picture two in cell 1 and so on and so on
Until now I didnt found a possibility to crop the pictures. Does anyone know a solution for this?
So far I managed to load 4 images inside, named 0,1,2,3.jpeg and arrange them in a grid.
Thanks in advance
- PImage[] fragment;
int tileCountX = 2;
int tileCountY = 2;
float tileWidth, tileHeight;
int imageCount = tileCountX*tileCountY;
int gridX = 0;
int gridY = 0;
void setup() {
size(400, 400);
smooth();
background(0);
noLoop();
fragment=new PImage[imageCount];
for(int i=0;i<fragment.length;i++){
fragment[i]=loadImage(str(i) + ".jpg");
}
tileWidth = width / (float)tileCountX;
tileHeight = height / (float)tileCountY;
}
void draw(){
float posX = tileWidth*gridX;
float posY = tileHeight*gridY;
gridX++;
if(gridX >= tileCountX) {
gridX = 0;
gridY++;
}
for(int i=0;i<fragment.length;i++){
for(float gridX = 0; gridX < width; gridX += tileWidth){
for (float gridY = 0; gridY < height; gridY += tileHeight){
image(fragment[i], gridX, gridY, tileWidth, tileHeight);
i++;
}
}
}
println(fragment);
}
1