Package com.sksamuel.scrimage.pixels
Class PixelTools
- java.lang.Object
-
- com.sksamuel.scrimage.pixels.PixelTools
-
public class PixelTools extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description PixelTools()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
alpha(int pixel)
Returns the alpha component of a pixel as a value between 0 and 255.static boolean
approx(java.awt.Color color, int tolerance, Pixel[] pixels)
Returns true if the colors of all pixels in the array are within the given tolerance compared to the referenced colorstatic int
argb(int a, int r, int g, int b)
Returns an encoded argb int from the given components.static int
blue(int pixel)
Returns the blue component of a pixel as a value between 0 and 255.static boolean
colorMatches(java.awt.Color color, int tolerance, Pixel[] pixels)
Returns true if the colors of all pixels in the array are within the given tolerance compared to the referenced color.static int
coordsToOffset(int x, int y, int w)
static int
gray(int pixel)
Returns the gray value of a pixel as a value between 0 and 255.static int
green(int pixel)
Returns the green component of a pixel as a value between 0 and 255.static java.awt.Point
offsetToPoint(int offset, int width)
Given a width and an offset returns the coordinate for that offset.static int
pointToOffset(java.awt.Point point, int w)
static int
red(int pixel)
Returns the red component of a pixel as a value between 0 and 255.static Pixel
replaceTransparencyWithColor(Pixel p, java.awt.Color color)
Returns a new Pixel with the transparency in the given pixel replaced by the given color.static int
rgb(int r, int g, int b)
Returns an encoded rgb int, with alpha 255, from the given components.static int
scale(java.lang.Double factor, int pixel)
Scales the brightness of a pixel.static int
truncate(java.lang.Double value)
static boolean
uniform(java.awt.Color color, Pixel[] pixels)
Returns true if all pixels in the array have the same color, or both are fully transparent.
-
-
-
Method Detail
-
rgb
public static int rgb(int r, int g, int b)
Returns an encoded rgb int, with alpha 255, from the given components.
-
argb
public static int argb(int a, int r, int g, int b)
Returns an encoded argb int from the given components.
-
alpha
public static int alpha(int pixel)
Returns the alpha component of a pixel as a value between 0 and 255.
-
red
public static int red(int pixel)
Returns the red component of a pixel as a value between 0 and 255.
-
green
public static int green(int pixel)
Returns the green component of a pixel as a value between 0 and 255.
-
blue
public static int blue(int pixel)
Returns the blue component of a pixel as a value between 0 and 255.
-
gray
public static int gray(int pixel)
Returns the gray value of a pixel as a value between 0 and 255.
-
truncate
public static int truncate(java.lang.Double value)
-
uniform
public static boolean uniform(java.awt.Color color, Pixel[] pixels)
Returns true if all pixels in the array have the same color, or both are fully transparent.
-
scale
public static int scale(java.lang.Double factor, int pixel)
Scales the brightness of a pixel.
-
approx
public static boolean approx(java.awt.Color color, int tolerance, Pixel[] pixels)
Returns true if the colors of all pixels in the array are within the given tolerance compared to the referenced color
-
colorMatches
public static boolean colorMatches(java.awt.Color color, int tolerance, Pixel[] pixels)
Returns true if the colors of all pixels in the array are within the given tolerance compared to the referenced color.If the given colour and target colour are both fully transparent, then they will match.
-
pointToOffset
public static int pointToOffset(java.awt.Point point, int w)
-
coordsToOffset
public static int coordsToOffset(int x, int y, int w)
-
offsetToPoint
public static java.awt.Point offsetToPoint(int offset, int width)
Given a width and an offset returns the coordinate for that offset. In other words, starting at 0,0 and moving along each row before starting the next row, it gives the coordinate that is kth from the start.
-
-