We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Here is my code. How am I able to mirror the left half of the picture using pixels?
PImage img;
void setup() {
img = loadImage("pic.JPG");
}
void draw() {
loadPixels();
img.loadPixels();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int iloc = x + y*width;
int cloc = (width - 1 - x) + y*width;
pixels[cloc] = img.pixels[iloc];
}
}
updatePixels();
}
Answers
You're close. I think the real issue is that your for loop for x goes from 0 to width, not to width/2.
I had to change a few things to get it to work, but this runs fine for me:
Also, consider this: