igede

Untitled

Nov 28th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. /**
  2.  * An image filter to make the image a bit darker.
  3.  *
  4.  * @author Gede
  5.  * @version 1.0(29/11/2018)
  6.  */
  7. public class DarkerFilter extends Filter
  8. {
  9.     /**
  10.      * Constructor for objects of class DarkerFilter.
  11.      * @param name The name of the filter.
  12.      */
  13.     public DarkerFilter(String name)
  14.     {
  15.         super(name);
  16.     }
  17.  
  18.     /**
  19.      * Apply this filter to an image.
  20.      *
  21.      * @param  image  The image to be changed by this filter.
  22.      */
  23.     public void apply(OFImage image)
  24.     {
  25.         int height = image.getHeight();
  26.         int width = image.getWidth();
  27.         for(int y = 0; y < height; y++) {
  28.             for(int x = 0; x < width; x++) {
  29.                 image.setPixel(x, y, image.getPixel(x, y).darker());
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment