Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.  
  2.  
  3. /**
  4.  * Write a description of class FlipHorizontalFilter here.
  5.  *
  6.  * @author Gede
  7.  * @version (10/12/2018)
  8.  */
  9. import java.awt.Color;
  10. public class FlipHorizontalFilter extends Filter
  11. {
  12.     /**
  13.      * Constructor for objects of class FlipVerticalFilter.
  14.      * @param name The name of the filter.
  15.      */
  16.     public FlipHorizontalFilter(String name)
  17.     {
  18.         super(name);
  19.     }
  20.  
  21.     /**
  22.      * Apply this filter to an image.
  23.      *
  24.      * @param  image  The image to be changed by this filter.
  25.      */
  26.     public void apply(OFImage image)
  27.     {
  28.         int height = image.getHeight();
  29.         int width = image.getWidth();
  30.         for(int y = 0; y < height/2; y++) {
  31.             for(int x = 0; x < width; x++) {
  32.                 Color left = image.getPixel(x, y);
  33.                 image.setPixel(x, y, image.getPixel(x, height-1-y));
  34.                 image.setPixel(x, height-1-y, left);
  35.             }
  36.         }
  37.     }
  38. }