/**
 * Starting Point Code for Image Processing Project
 * @author Richard Wicentowski and Tia Newhall (2005)
 * Modified by Kuzman Ganchev
 */

public class FlipHorizontal extends Manipulator{

  public String getManipulationName(){
    return "Flip Horizontal";
  }

  /** Flips the image horizontally.
    * @param picture The image to flip
    * @return The flipped image
    */
  public Pixel[][] processImage(Pixel[][] picture) {
    // if the picture has no rows, then there's nothing to do
    if (picture.length > 0) {    
      Pixel temp;
      for (int x = 0; x < picture.length/2; x++) {
        for (int y = 0; y < picture[0].length; y++) {
          temp = picture[x][y];
          picture[x][y] = picture[picture.length-1-x][y];
          picture[picture.length-1-x][y] = temp;
        }
      }
    }
    return picture;
  }
}



