title: Flipping an image in java
body: <p>I'm trying to flip an image in java, but I ran into a problem that I just cannot figure out.</p>
  
  <p>Using a double-for-loop, I'm running through all pixelvalues in the org image, and copying them to the new image in the pixel(width-x-1,y).</p>
  
  <p>The following picture depicts, what happens when I run the method.</p>
  
  <p><a href="http://tinypic.com/r/nqzsiu/8" rel="nofollow">http://tinypic.com/r/nqzsiu/8</a></p>
  
  <p>The new image, only seems to run through 1/10 of the image' height for some reason. Why is this and how do I fix it?</p>
  
  <pre><code>private Image img;
  private Pixel pixel;
  private Image newimg;
  private Pixel newpixel;
  
  public advancedFilters(Image img)
  {
      this.img = img;
  }
  
  public Image Mirror(){
      newimg = new Image(img.getWidth(), img.getHeight(), "newimage");
      int curtone;
      for (int j=0; j&lt;img.getHeight(); j++) {
          for (int i=0; i&lt;img.getWidth(); i++) {
              pixel = img.getPixel(i,j);
              curtone = pixel.getValue();
              newpixel = newimg.getPixel(newimg.getWidth()-i-1, j);
              newpixel.setValue(curtone);
  
          }
      }
      return newimg;
  }
  </code></pre>