java.lang.Object
fr.olleroy.ImageModifier.components.Pixel

public class Pixel extends Object
An RGB or ARGB Pixel (24 bits or 32 bits).
Version:
1.2.0
Author:
olleroy alias ollprogram
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a black pixel.
    Pixel​(int color)
    Construct a pixel with the specified argb color (with alpha).
    Pixel​(int r, int g, int b)
    Construct a pixel with the specified rgb color without alpha value (default 255).
    Pixel​(int a, int r, int g, int b)
    Construct a pixel with the specified ARGB color.
    Pixel​(Color color)
    Construct a pixel with the specified color.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    ARGBtoInt​(int a, int r, int g, int b)
    Convert ARGB to integer.
    boolean
    equals​(Object o)
     
    int
    Get alpha.
    int
    Get the ARGB color.
    int
    Get blue color.
    int
    Get green color.
    int
    Get red color.
    int
    Get the RGB color.
    int
     
    static int[]
    parseARGB​(int a, int r, int g, int b)
    Parse the ARGB values.
    static int
    RGBtoInt​(int r, int g, int b)
    Convert RGB to integer.
    void
    setAlpha​(int alpha)
    Set alpha.
    void
    setBlue​(int blue)
    Set blue color.
    void
    setColor​(int color)
    Construct a pixel with the specified color.
    void
    setColor​(int r, int g, int b)
    Set the RGB color of the Pixel (Alpha = 255 by default).
    void
    setColor​(int a, int r, int g, int b)
    Set the ARGB color of the Pixel.
    void
    setColor​(Color color)
    Set the color of the Pixel.
    void
    setGreen​(int green)
    Set green color.
    void
    setRed​(int red)
    Set red color.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Pixel

      public Pixel()
      Construct a black pixel.
    • Pixel

      public Pixel(Color color)
      Construct a pixel with the specified color.
      Parameters:
      color - the Color.
    • Pixel

      public Pixel(int color)
      Construct a pixel with the specified argb color (with alpha).
      Parameters:
      color - The color in classic ARGB format.
    • Pixel

      public Pixel(int r, int g, int b)
      Construct a pixel with the specified rgb color without alpha value (default 255).
      Parameters:
      r - Red color.
      g - Green color.
      b - Blue color.
    • Pixel

      public Pixel(int a, int r, int g, int b)
      Construct a pixel with the specified ARGB color.
      Parameters:
      a - Alpha.
      r - Red color.
      g - Green color.
      b - Blue color.
  • Method Details

    • parseARGB

      public static int[] parseARGB(int a, int r, int g, int b)
      Parse the ARGB values.
      Parameters:
      a - Alpha.
      r - Red color.
      g - Green color.
      b - Blue color.
      Returns:
      An array of 4 elements {alpha, red, green, blue}. All elements are from 0 to 255.
    • ARGBtoInt

      public static int ARGBtoInt(int a, int r, int g, int b)
      Convert ARGB to integer.
      Parameters:
      a - Alpha.
      r - Red color.
      g - Green color.
      b - Blue color.
      Returns:
      An integer of the ARGB color in the classic ARGB format.
    • RGBtoInt

      public static int RGBtoInt(int r, int g, int b)
      Convert RGB to integer.
      Parameters:
      r - Red color.
      g - Green color.
      b - Blue color.
      Returns:
      The integer of the color in RGB format.
    • setColor

      public void setColor(int r, int g, int b)
      Set the RGB color of the Pixel (Alpha = 255 by default).
      Parameters:
      r - Red color.
      g - Green color.
      b - Blue color.
    • setColor

      public void setColor(int a, int r, int g, int b)
      Set the ARGB color of the Pixel.
      Parameters:
      a - Alpha.
      r - Red color.
      g - Green color.
      b - Blue color.
    • setColor

      public void setColor(Color color)
      Set the color of the Pixel.
      Parameters:
      color - A color from the awt library.
    • setColor

      public void setColor(int color)
      Construct a pixel with the specified color.
      Parameters:
      color - An ARGB color in classic RGB format.
    • getRed

      public int getRed()
      Get red color.
      Returns:
      The red color of the pixel.
    • setRed

      public void setRed(int red)
      Set red color.
      Parameters:
      red - The red color of the pixel to set.
    • getGreen

      public int getGreen()
      Get green color.
      Returns:
      The green color of the pixel.
    • setGreen

      public void setGreen(int green)
      Set green color.
      Parameters:
      green - The green color of the pixel to set.
    • getBlue

      public int getBlue()
      Get blue color.
      Returns:
      The blue color of the pixel.
    • setBlue

      public void setBlue(int blue)
      Set blue color.
      Parameters:
      blue - The blue color of the pixel to set
    • setAlpha

      public void setAlpha(int alpha)
      Set alpha.
      Parameters:
      alpha - The alpha of the pixel
    • getAlpha

      public int getAlpha()
      Get alpha.
      Returns:
      The alpha value of the pixel.
    • getARGB

      public int getARGB()
      Get the ARGB color.
      Returns:
      Integer of the ARGB color.
    • getRGB

      public int getRGB()
      Get the RGB color.
      Returns:
      Integer of the RGB color.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object