title: How to mirror an image with Java.awt
body: <p>I have an assignment to be done in Java, and I can't figure this out for the life of me. I'm supposed to use Graphics2D and Java.AWT. to mirror an image across both the x-axis and y-axis. </p>
  
  <p>Current code is: </p>
  
  <pre><code>import java.awt.Graphics;
  import java.awt.Graphics2D;
  import java.awt.Color;
  public class DrawingImages
  {
  private Picture newCanvas = null;
  private Graphics g = null;
  private Graphics2D g2 = null;
  private Picture pic1 = null;
  private Picture pic2 = null;
  private Color color = null;
  private Pixel sourcePixel, targetPixel = null;
  private Color sourceColor, targetColor = null;
  
  DrawingImages(Picture canv, Color col)
  {
      Picture sourcePicture = new Picture("WashingtonMonument.jpg");
      newCanvas = canv;
      newCanvas.setAllPixelsToAColor(Color.BLACK);
      for(int y = sourcePicture.getHeight()-1; y &gt;0; y=y-1)
      {
          for(int x = sourcePicture.getWidth() - 1; x &gt; 0; x = x - 1)
          {
              sourcePixel = sourcePicture.getPixel(x,y);
              sourceColor = sourcePixel.getColor();
              targetPixel = newCanvas.getPixel(x+sourcePicture.getWidth() -1,y+sourcePicture.getHeight()- 1);
              targetPixel.setColor(sourceColor);         
          }
      }
  
  
      g = newCanvas.getGraphics();
      g2 = (Graphics2D)g;  
  }
  </code></pre>
  
  <p>}</p>