String fileName = FileChooser.pickAFile();
Picture pict = new Picture (fileName);
// create the canvas for the mirrored image
Picture pictNew = new Picture (pict.getWidth(), pict.getHeight());
int index;
Pixel pix, pixNew, pixNew2, pixNew3;;
int xPos, yPos;
int red, green, blue;
// set up two loops; one nested inside the other
int xIndex, yIndex;
for (xIndex = 0 ; xIndex < pict.getWidth() ; xIndex++)
{
for (yIndex = 0 ; yIndex < pict.getHeight() ; yIndex++)
{
// Access the pixel from the orignal image
pix = pict.getPixel (xIndex, yIndex);
// Access the correct pixel from the new Image
pixNew = pictNew.getPixel (pict.geWidth - xIndex - 1,
pict.getHeight() - yIndex - 1);
// access the 3 color intensities
red = pix.getRed();
green = pix.getGreen();
blue = pix.getBlue();
// copy into the rotated image
pixNew.setRed(green);
pixNew.setGreen(blue);
pixNew.setBlue(red);
}
}
pictNew.show();
fileName = FileChooser.pickAFile();
pict.write (fileName);