daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Dec 10th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.*;
  2. import java.awt.image.*;
  3. import javax.swing.*;
  4.  
  5. /**
  6.  * Ujian Akhir Semester
  7.  * Kelas PBO B
  8.  * @author Hendra Ramadani (05111740000055)
  9.  * 10 December 2018
  10.  */
  11. public class OFImage extends BufferedImage
  12. {
  13.     /**
  14.      * Create an OFImage copied from a BufferedImage.
  15.      * @param image The image to copy.
  16.      */
  17.     public OFImage(BufferedImage image)
  18.     {
  19.          super(image.getColorModel(), image.copyData(null),
  20.                image.isAlphaPremultiplied(), null);
  21.     }
  22.  
  23.     /**
  24.      * Create an OFImage with specified size and unspecified content.
  25.      * @param width The width of the image.
  26.      * @param height The height of the image.
  27.      */
  28.     public OFImage(int width, int height)
  29.     {
  30.         super(width, height, TYPE_INT_RGB);
  31.     }
  32.  
  33.     /**
  34.      * Set a given pixel of this image to a specified color. The
  35.      * color is represented as an (r,g,b) value.
  36.      * @param x The x position of the pixel.
  37.      * @param y The y position of the pixel.
  38.      * @param col The color of the pixel.
  39.      */
  40.     public void setPixel(int x, int y, Color col)
  41.     {
  42.         int pixel = col.getRGB();
  43.         setRGB(x, y, pixel);
  44.     }
  45.    
  46.     /**
  47.      * Get the color value at a specified pixel position.
  48.      * @param x The x position of the pixel.
  49.      * @param y The y position of the pixel.
  50.      * @return The color of the pixel at the given position.
  51.      */
  52.     public Color getPixel(int x, int y)
  53.     {
  54.         int pixel = getRGB(x, y);
  55.         return new Color(pixel);
  56.     }
  57. }
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