I'm new to Java and I really need some help! I need to write a method to mirror the left half of a picture to the right half of the picture motorcycle.jpg (see attachment for example). I have a method, but it flips the image and copies it to a new picture. I need the method to take half of the image and mirror it over the other half of the image. Please help!
public Picture flip() { Pixel currPixel = null; Pixel targetPixel = null; Picture target = new Picture(FileChooser.pickAFile()); for (int srcX = 0, trgX = getWidth()-1; srcX < getWidth(); srcX++, trgX--) { for (int srcY = 0, trgY = 0; srcY < getHeight(); srcY++, trgY++) { // get the current pixel currPixel = this.getPixel(srcX,srcY); targetPixel = target.getPixel(trgX,trgY); // copy the color of currPixel into target targetPixel.setColor(currPixel.getColor()); } } return target; }