Class ColorUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intABGRtoARGB(int abgr) static float[]ABGRtoHSB(int abgr) static intARGBtoABGR(int argb) static float[]ARGBtoHSB(int argb) static intHSBtoRGB(float hue, float saturation, float brightness) Converts the components of a color, as specified by the HSB model, to an equivalent set of values for the default RGB model.static float[]RGBtoHSB(int r, int g, int b, float[] hsbvals) Converts the components of a color, as specified by the default RGB model, to an equivalent set of values for hue, saturation, and brightness that are the three components of the HSB model.
-
Constructor Details
-
ColorUtils
public ColorUtils()
-
-
Method Details
-
HSBtoRGB
public static int HSBtoRGB(float hue, float saturation, float brightness) Converts the components of a color, as specified by the HSB model, to an equivalent set of values for the default RGB model.The
saturationandbrightnesscomponents should be floating-point values between zero and one (numbers in the range 0.0-1.0). Thehuecomponent can be any floating-point number. The floor of this number is subtracted from it to create a fraction between 0 and 1. This fractional number is then multiplied by 360 to produce the hue angle in the HSB color model.The integer that is returned by
HSBtoRGBencodes the value of a color in bits 0-23 of an integer value that is the same format used by the method#getRGB() getRGB. This integer can be supplied as an argument to theColorconstructor that takes a single integer argument.- Parameters:
hue- the hue component of the colorsaturation- the saturation of the colorbrightness- the brightness of the color- Returns:
- the RGB value of the color with the indicated hue, saturation, and brightness.
-
RGBtoHSB
public static float[] RGBtoHSB(int r, int g, int b, float[] hsbvals) Converts the components of a color, as specified by the default RGB model, to an equivalent set of values for hue, saturation, and brightness that are the three components of the HSB model.If the
hsbvalsargument isnull, then a new array is allocated to return the result. Otherwise, the method returns the arrayhsbvals, with the values put into that array.- Parameters:
r- the red component of the colorg- the green component of the colorb- the blue component of the colorhsbvals- the array used to return the three HSB values, ornull- Returns:
- an array of three elements containing the hue, saturation, and brightness (in that order), of the color with the indicated red, green, and blue components.
-
ARGBtoHSB
public static float[] ARGBtoHSB(int argb) -
ABGRtoHSB
public static float[] ABGRtoHSB(int abgr) -
ARGBtoABGR
public static int ARGBtoABGR(int argb) -
ABGRtoARGB
public static int ABGRtoARGB(int abgr)
-