Hey everyone, i am new here and to java. I am currently just starting to learn java and have a problem trying to figure out a simple method. I am writing methods to rotate images, i can do left and right, but cannot make it rotate 180 degree's. I thought it would be as easy as copying and pasting a few lines or multiplying some of the ints from one of my other methods(bottom method is from my rotate right method), any advice or suggestions?
Thanks
public void copyPictureLeftRotation(Picture sourcePic) { Picture targetPicture = this; Pixel sourcePixel = null; Pixel targetPixel = null; int targetX, targetY = 0; int width = sourcePic.getWidth(); int height = sourcePic.getHeight(); // loop through the rows for (int sourceX = 0; sourceX < width; sourceX++) { // loop through the colomns for (int sourceY = 0; sourceY < height; sourceY++) { // set the target pixel color to the source pixel color sourcePixel = sourcePic.getPixel(sourceX,sourceY); targetX = sourceY; targetY = width - 1 - sourceX; targetPixel = targetPicture.getPixel(targetX,targetY); targetPixel.setColor(sourcePixel.getColor()); } } }