Class ScaledColorSpace
java.lang.Object
java.awt.color.ColorSpace
org.apache.sis.internal.coverage.j2d.ScaledColorSpace
- All Implemented Interfaces:
Serializable
Color space for images storing pixels as real numbers. This color space can have an arbitrary number of bands,
but only one band is shown. Current implementation produces grayscale image only, but it may change in future.
The use of this color space is very slow. It should be used only when no standard color space can be used.
- Since:
- 1.0
- Version:
- 1.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final double
The maximum value specified at construction time.(package private) final double
The offset to subtract from sample values before to apply the scale factor.(package private) final double
The scaling factor from sample values to RGB values.private static final long
For cross-version compatibility.(package private) final int
Index of the band to display, from 0 inclusive toColorSpace.getNumComponents()
exclusive.Fields inherited from class java.awt.color.ColorSpace
CS_CIEXYZ, CS_GRAY, CS_LINEAR_RGB, CS_PYCC, CS_sRGB, TYPE_2CLR, TYPE_3CLR, TYPE_4CLR, TYPE_5CLR, TYPE_6CLR, TYPE_7CLR, TYPE_8CLR, TYPE_9CLR, TYPE_ACLR, TYPE_BCLR, TYPE_CCLR, TYPE_CMY, TYPE_CMYK, TYPE_DCLR, TYPE_ECLR, TYPE_FCLR, TYPE_GRAY, TYPE_HLS, TYPE_HSV, TYPE_Lab, TYPE_Luv, TYPE_RGB, TYPE_XYZ, TYPE_YCbCr, TYPE_Yxy
-
Constructor Summary
ConstructorsConstructorDescriptionScaledColorSpace
(int numComponents, int visibleBand, double minimum, double maximum) Creates a color space for the given range of values.ScaledColorSpace
(ScaledColorSpace parent, int[] bands) Creates a color space for the same range of values than the given space, but a subset of the bands. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares this color space with the given object for equality.(package private) final void
formatRange
(StringBuilder buffer) Formats the range of values in the given buffer.float[]
fromCIEXYZ
(float[] color) Returns a sample value for the specified CIEXYZ color.float[]
fromRGB
(float[] color) Returns a sample value for the specified RGB color.float
getMaxValue
(int component) Returns the maximum value for the specified RGB component.float
getMinValue
(int component) Returns the minimum value for the specified RGB component.int
hashCode()
Returns a hash code value for this color space.float[]
toCIEXYZ
(float[] values) Returns a CIEXYZ color for a sample value.float[]
toRGB
(float[] samples) Returns a RGB color for a sample value.toString()
Returns a string representation of this color space.Methods inherited from class java.awt.color.ColorSpace
getInstance, getName, getNumComponents, getType, isCS_sRGB
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
scale
final double scaleThe scaling factor from sample values to RGB values. The target RGB values will be in range 0 to 255 inclusive. Note that the target range is different than the range ofColorSpace
normalized values; methods in this class has to divide values by 256. -
offset
final double offsetThe offset to subtract from sample values before to apply the scale factor. -
maximum
final double maximumThe maximum value specified at construction time. -
visibleBand
final int visibleBandIndex of the band to display, from 0 inclusive toColorSpace.getNumComponents()
exclusive.
-
-
Constructor Details
-
ScaledColorSpace
ScaledColorSpace(int numComponents, int visibleBand, double minimum, double maximum) Creates a color space for the given range of values. The given range does not need to be exact; values outside that range will be clamped.- Parameters:
numComponents
- the number of components.visibleBand
- the band to use for computing colors.minimum
- the minimal sample value expected, inclusive.maximum
- the maximal sample value expected, exclusive.
-
ScaledColorSpace
ScaledColorSpace(ScaledColorSpace parent, int[] bands) Creates a color space for the same range of values than the given space, but a subset of the bands.
-
-
Method Details
-
toRGB
public float[] toRGB(float[] samples) Returns a RGB color for a sample value.- Specified by:
toRGB
in classColorSpace
- Parameters:
samples
- sample values in the raster.- Returns:
- color as normalized RGB values between 0 and 1.
-
fromRGB
public float[] fromRGB(float[] color) Returns a sample value for the specified RGB color.- Specified by:
fromRGB
in classColorSpace
- Parameters:
color
- normalized RGB values between 0 and 1.- Returns:
- sample values in the raster.
-
toCIEXYZ
public float[] toCIEXYZ(float[] values) Returns a CIEXYZ color for a sample value.- Specified by:
toCIEXYZ
in classColorSpace
- Parameters:
values
- sample values in the raster.- Returns:
- color as normalized CIEXYZ values between 0 and 1.
-
fromCIEXYZ
public float[] fromCIEXYZ(float[] color) Returns a sample value for the specified CIEXYZ color.- Specified by:
fromCIEXYZ
in classColorSpace
- Parameters:
color
- normalized CIEXYZ values between 0 and 1.- Returns:
- sample values in the raster.
-
getMinValue
public float getMinValue(int component) Returns the minimum value for the specified RGB component.- Overrides:
getMinValue
in classColorSpace
- Parameters:
component
- the component index.- Returns:
- minimum normalized component value.
-
getMaxValue
public float getMaxValue(int component) Returns the maximum value for the specified RGB component.- Overrides:
getMaxValue
in classColorSpace
- Parameters:
component
- the component index.- Returns:
- maximum normalized component value.
-
toString
Returns a string representation of this color space. -
formatRange
Formats the range of values in the given buffer. This method is used fortoString()
implementation and may change in any future version.- Parameters:
buffer
- where to append the range of values.
-
hashCode
public int hashCode()Returns a hash code value for this color space. -
equals
Compares this color space with the given object for equality.
-