Package com.sksamuel.scrimage.pixels
Class Pixel
- java.lang.Object
-
- com.sksamuel.scrimage.pixels.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.
-
-
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()
-
-
-
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.
-
toColor
public RGBColor toColor()
-
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 classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-