| java.lang.Object org.geotools.resources.image.ColorUtilities
ColorUtilities | final public class ColorUtilities (Code) | | A set of static methods for handling of colors informations. Some of those methods
are useful, but not really rigorous. This is why they do not appear in any "official"
package, but instead in this private one.
Do not rely on this API!
It may change in incompatible way in any future version.
since: 2.0 version: $Id: ColorUtilities.java 26799 2007-08-31 21:31:21Z desruisseaux $ author: Martin Desruisseaux author: Simone Giannecchini |
Method Summary | |
public static float[] | XYZtoLAB(float[] color) Transforms a color from XYZ color space to LAB. | public static float | colorDistance(float[] lab1, float[] lab2) Computes the distance E (CIE 1994) between two colors in LAB color space. | public static void | expand(Color[] colors, int[] ARGB, int lower, int upper) Copy
colors into array
ARGB from index
lower inclusive to index
upper exclusive. | public static int | getBitCount(int mapSize) Returns a bit count for an
IndexColorModel mapping
mapSize colors. | public static int | getColorIndex(IndexColorModel colors, Color color, int exclude) Returns the index of the specified color, excluding the specified one. | public static IndexColorModel | getIndexColorModel(int[] ARGB) Returns an index color model for specified ARGB codes. | public static IndexColorModel | getIndexColorModel(int[] ARGB, int numBands, int visibleBand) Returns a tolerant index color model for the specified ARGB code. | public static int | getIntFromColor(int r, int g, int b, int a) Creates an sRGB color with the specified red, green, blue, and alpha
values in the range (0 - 255). | public static int | getNumBands(ColorModel model) Tries to guess the number of bands from the specified color model. | public static int | getTransferType(int mapSize) Returns a suggered type for an
IndexColorModel of
mapSize colors. | public static int | getTransparentPixel(IndexColorModel colors) Returns the most transparent pixel in the specified color model. | public static boolean | isGrayPalette(IndexColorModel icm, boolean ignoreTransparents) Tells us if a specific
IndexColorModel contains only gray color
or not, ignoring alpha information.
Parameters: icm - IndexColorModel to be inspected. Parameters: ignoreTransparents - true if the RGB values of fully transparent pixels(the ones with an value of 0)should not be taken in account during the check for gray color. | public static int | roundByte(double value) Round a float value and clamp the
result between 0 and 255 inclusive. | public static Color[] | subarray(Color[] palette, int lower, int upper) Returns a subarray of the specified color array. |
XYZtoLAB | public static float[] XYZtoLAB(float[] color)(Code) | | Transforms a color from XYZ color space to LAB. The color are transformed
in place. This method returns
color for convenience.
Reference: http://www.brucelindbloom.com/index.html?ColorDifferenceCalc.html
|
colorDistance | public static float colorDistance(float[] lab1, float[] lab2)(Code) | | Computes the distance E (CIE 1994) between two colors in LAB color space.
Reference: http://www.brucelindbloom.com/index.html?ColorDifferenceCalc.html
|
expand | public static void expand(Color[] colors, int[] ARGB, int lower, int upper)(Code) | | Copy
colors into array
ARGB from index
lower inclusive to index
upper exclusive. If
upper-lower is not
equals to the length of
colors array, then colors will be interpolated.
Parameters: colors - Colors to copy into the ARGB array. Parameters: ARGB - Array of integer to write ARGB values to. Parameters: lower - Index (inclusive) of the first element of ARGB to change. Parameters: upper - Index (exclusive) of the last element of ARGB to change. |
getBitCount | public static int getBitCount(int mapSize)(Code) | | Returns a bit count for an
IndexColorModel mapping
mapSize colors.
It is guaranteed that the following relation is hold:
(1 << getBitCount(mapSize)) >= mapSize
|
getColorIndex | public static int getColorIndex(IndexColorModel colors, Color color, int exclude)(Code) | | Returns the index of the specified color, excluding the specified one. If the color
is not explicitly found, a close color is returned. This method never returns a negative
value (0 is returned if the color model has no colors).
Parameters: colors - The color model in which to look for a color index. Parameters: color - The color to search for. Parameters: exclude - An index to exclude from the search (usually the background or the pixel), or -1 if none. The index of the color, or 0. |
getIndexColorModel | public static IndexColorModel getIndexColorModel(int[] ARGB)(Code) | | Returns an index color model for specified ARGB codes. If the specified
array has not transparent color (i.e. all alpha values are 255), then the
returned color model will be opaque. Otherwise, if the specified array has
one and only one color with alpha value of 0, the returned color model will
have only this transparent color. Otherwise, the returned color model will
be translucent.
Parameters: ARGB - An array of ARGB values. An index color model for the specified array. |
getIndexColorModel | public static IndexColorModel getIndexColorModel(int[] ARGB, int numBands, int visibleBand)(Code) | | Returns a tolerant index color model for the specified ARGB code. This color model accept
image with the specified number of bands.
Parameters: ARGB - An array of ARGB values. Parameters: numBands - The number of bands. Parameters: visibleBand - The band to display. An index color model for the specified array. |
getIntFromColor | public static int getIntFromColor(int r, int g, int b, int a)(Code) | | Creates an sRGB color with the specified red, green, blue, and alpha
values in the range (0 - 255).
Parameters: r - the red component Parameters: g - the green component Parameters: b - the blue component Parameters: a - the alpha component throws: IllegalArgumentException - if , g , b or a are outside of the range 0 to 255, inclusive. |
getNumBands | public static int getNumBands(ColorModel model)(Code) | | Tries to guess the number of bands from the specified color model. The recommanded approach
is to invoke
java.awt.image.SampleModel.getNumBands . This method should be used only
as a fallback when the sample model is not available. This method uses some heuristic rules
for guessing the number of bands, so the return value may not be exact in all cases.
|
getTransferType | public static int getTransferType(int mapSize)(Code) | | Returns a suggered type for an
IndexColorModel of
mapSize colors. This method returns
DataBuffer.TYPE_BYTE or
DataBuffer.TYPE_USHORT .
|
getTransparentPixel | public static int getTransparentPixel(IndexColorModel colors)(Code) | | Returns the most transparent pixel in the specified color model. If many colors has
the same alpha value, than the darkest one is returned. This method never returns
a negative value (0 is returned if the color model has no colors).
Parameters: colors - The color model in which to look for a transparent color. The index of a transparent color, or 0. |
isGrayPalette | public static boolean isGrayPalette(IndexColorModel icm, boolean ignoreTransparents)(Code) | | Tells us if a specific
IndexColorModel contains only gray color
or not, ignoring alpha information.
Parameters: icm - IndexColorModel to be inspected. Parameters: ignoreTransparents - true if the RGB values of fully transparent pixels(the ones with an value of 0)should not be taken in account during the check for gray color. true if the palette is grayscale, false otherwise. |
roundByte | public static int roundByte(double value)(Code) | | Round a float value and clamp the
result between 0 and 255 inclusive.
|
subarray | public static Color[] subarray(Color[] palette, int lower, int upper)(Code) | | Returns a subarray of the specified color array. The
lower and
upper index will be clamb into the
palette range.
If they are completly out of range, or if they would result in an empty array,
then
null is returned.
This method is used by
org.geotools.cv.SampleDimension as an heuristic
approach for distributing palette colors into a list of categories.
Parameters: palette - The color array (may be null ). Parameters: lower - The lower index, inclusive. Parameters: upper - The upper index, inclusive. The subarray (may be palette if the original array already fit),or null if the lower and upper indexare out of palette bounds. |
|
|