daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Dec 10th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.Color;
  2.  
  3. /**
  4.  * Ujian Akhir Semester
  5.  * Kelas PBO B
  6.  * @author Hendra Ramadani (05111740000055)
  7.  * 10 December 2018
  8.  */
  9. public class SolarizeFilter extends Filter
  10. {
  11.     /**
  12.      * Constructor for objects of class Solarize.
  13.      * @param name The name of the filter.
  14.      */
  15.     public SolarizeFilter(String name)
  16.     {
  17.         super(name);
  18.     }
  19.  
  20.     /**
  21.      * Apply this filter to an image.
  22.      *
  23.      * @param  image  The image to be changed by this filter.
  24.      */
  25.     public void apply(OFImage image)
  26.     {
  27.         int height = image.getHeight();
  28.         int width = image.getWidth();
  29.         for(int y = 0; y < height; y++) {
  30.             for(int x = 0; x < width; x++) {
  31.                 Color pix = image.getPixel(x, y);
  32.                 int red = pix.getRed();
  33.                 if(red <= 127) {
  34.                     red = 255 - red;
  35.                 }
  36.                 int green = pix.getGreen();
  37.                 if(green <= 127) {
  38.                     green = 255 - green;
  39.                 }
  40.                 int blue = pix.getBlue();
  41.                 if(blue <= 127) {
  42.                     blue = 255 - blue;
  43.                 }
  44.                 image.setPixel(x, y, new Color(red, green, blue));
  45.             }
  46.         }
  47.     }
  48.  
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top