Class Pixel


  • public class Pixel
    extends java.lang.Object
    A pixel is an encoding of a color value at a specific location in a Raster. The pixel is encoded using an ARGB packed int.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int argb  
      int x  
      int y  
    • Constructor Summary

      Constructors 
      Constructor Description
      Pixel​(int x, int y, int argb)  
      Pixel​(int x, int y, int r, int g, int b, int alpha)  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      int alpha()  
      Pixel alpha​(int a)
      Returns a copy of this pixel, with the same red, green, blue values, but with alpha set to the given value.
      int average()  
      int blue()  
      Pixel blue​(int b)
      Returns a copy of this pixel with the blue component set to the given value.
      boolean equals​(java.lang.Object o)  
      Pixel fullalpha()
      Returns a copy of this pixel, with the same red, green, blue values, but with alpha set to fully transparent (0).
      int green()  
      Pixel green​(int g)
      Returns a copy of this pixel with the green component set to the given value.
      int hashCode()  
      Pixel mapByComponent​(java.util.function.Function<java.lang.Integer,​java.lang.Integer> f)  
      Pixel noalpha()
      Returns a copy of this pixel, with the same red, green, blue values, but with alpha set to fully opaque (255).
      int red()  
      Pixel red​(int r)
      Returns a copy of this pixel with the red component set to the given value.
      int[] toARGB()
      Returns this pixel as an array of ARGB values.
      int toARGBInt()
      Returns this pixel as a packed ARGB int.
      Pixel toAverageGrayscale()
      Returns a copy of this Pixel with the colour as grayscale using the average method.
      RGBColor toColor()  
      int toInt()
      Deprecated.
      int[] toRGB()
      Returns this pixel as an array of RGB values, ignoring any alpha value.
      java.lang.String toString()  
      int x()  
      int y()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • argb

        public final int argb
      • x

        public final int x
      • y

        public final int y
    • Constructor Detail

      • Pixel

        public Pixel​(int x,
                     int y,
                     int argb)
      • Pixel

        public Pixel​(int x,
                     int y,
                     int r,
                     int g,
                     int b,
                     int alpha)
    • Method Detail

      • alpha

        public int alpha()
      • red

        public int red()
      • green

        public int green()
      • blue

        public int blue()
      • average

        public int average()
      • x

        public int x()
      • y

        public int y()
      • toInt

        @Deprecated
        public int toInt()
        Deprecated.
      • toARGBInt

        public int toARGBInt()
        Returns this pixel as a packed ARGB int.
      • alpha

        public Pixel alpha​(int a)
        Returns a copy of this pixel, with the same red, green, blue values, but with alpha set to the given value.
      • noalpha

        public Pixel noalpha()
        Returns a copy of this pixel, with the same red, green, blue values, but with alpha set to fully opaque (255).
      • fullalpha

        public Pixel fullalpha()
        Returns a copy of this pixel, with the same red, green, blue values, but with alpha set to fully transparent (0).
      • red

        public Pixel red​(int r)
        Returns a copy of this pixel with the red component set to the given value.
      • green

        public Pixel green​(int g)
        Returns a copy of this pixel with the green component set to the given value.
      • blue

        public Pixel blue​(int b)
        Returns a copy of this pixel with the blue component set to the given value.
      • toARGB

        public int[] toARGB()
        Returns this pixel as an array of ARGB values.
      • toAverageGrayscale

        public Pixel toAverageGrayscale()
        Returns a copy of this Pixel with the colour as grayscale using the average method. The Average method takes the average value of R, G, and B as the grayscale value.
      • toRGB

        public int[] toRGB()
        Returns this pixel as an array of RGB values, ignoring any alpha value.
      • mapByComponent

        public Pixel mapByComponent​(java.util.function.Function<java.lang.Integer,​java.lang.Integer> f)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object