Class LabColorSpace
- java.lang.Object
-
- java.awt.color.ColorSpace
-
- org.faceless.pdf2.LabColorSpace
-
- All Implemented Interfaces:
Serializable
public class LabColorSpace extends ColorSpace
Represents the CIE 1976 (L*, a*, b*) or "CIELAB" device-independent ColorSpace. Colors from this ColorSpace can be used like any other color from the RGB or
CMYK
ColorSpaces, although they are most useful when specifying alternates forSpot
colors.Technically you also need to specify the CIE illuminant to completely define the color, but usually the intention is to define an exact color for print output, so the D50 illuminant is assumed. If you require a D65 illuminant the
getColorD65(float, float, float)
method can be called.For example, here are three ways to specify the Color "PANTONE® Reflex Blue C" - the first using L*a*b values in CIELAB space with a D50 illuminant, the second in the same space with a D65 illuminant, and the third using a CMYK process colorspace. Note that the third approach is an approximation only as this particular shade can not normally be reproduced using a four-color process, which is why using Lab colors as alternatives for Spot colors is the best option if possible.
Color blue = SpotColorSpace.getInstance("Pantone Reflex Blue C", LabColorSpace.getColor(19, 26, -68)); Color blue = SpotColorSpace.getInstance("Pantone Reflex Blue C", LabColorSpace.getColorD65(26.18, 18.64, -59.93)); Color blue = SpotColorSpace.getInstance("Pantone Reflex Blue C", CMYKColorSpace.getColor(1, 0.73f, 0, 0.02f));
- Since:
- 2.14.1
- See Also:
- Serialized Form
-
-
Field Summary
-
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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static List<Map.Entry<Float,Color>>
convertGradient(List<Map.Entry<Float,Color>> in, ColorSpace target, ColorSpace interpolation, String options)
Given a list of [Fraction,Color] pairs in one (or more) ColorSpaces representing a Gradient, return a List representing the same gradient in the specified target ColorSpace, ensuring that each Color is within the specified tolerance.boolean
equals(Object o)
float[]
fromCIEXYZ(float[] xyz)
float[]
fromRGB(float[] rgb)
static Color
getColor(float L, float a, float b)
Get a Color in the standard CIELAB D50 ColorSpace, based on the D50 illuminant.static Color
getColor(float L, float a, float b, float alpha)
Get a Color in the standard CIELAB D50 ColorSpace, based on the D50 illuminant.static Color
getColorD65(float L, float a, float b)
Get a Color in the CIELAB ColorSpace, based on the D65 illuminant.static LabColorSpace
getInstance()
Return a standard instance of the Lab Colorspace, with a D50 whitepointfloat
getMaxValue(int c)
float
getMinValue(int c)
String
getName(int i)
int
hashCode()
float[]
toCIEXYZ(float[] lab)
Note this method will typically be called when converting a bitmap, and we have to map fromfloat[]
toRGB(float[] lab)
String
toString()
-
Methods inherited from class java.awt.color.ColorSpace
getInstance, getNumComponents, getType, isCS_sRGB
-
-
-
-
Method Detail
-
getInstance
public static final LabColorSpace getInstance()
Return a standard instance of the Lab Colorspace, with a D50 whitepoint- Since:
- 2.26
-
getName
public String getName(int i)
- Overrides:
getName
in classColorSpace
-
toRGB
public float[] toRGB(float[] lab)
- Specified by:
toRGB
in classColorSpace
-
fromRGB
public float[] fromRGB(float[] rgb)
- Specified by:
fromRGB
in classColorSpace
-
fromCIEXYZ
public float[] fromCIEXYZ(float[] xyz)
- Specified by:
fromCIEXYZ
in classColorSpace
-
getMinValue
public float getMinValue(int c)
- Overrides:
getMinValue
in classColorSpace
-
getMaxValue
public float getMaxValue(int c)
- Overrides:
getMaxValue
in classColorSpace
-
toCIEXYZ
public float[] toCIEXYZ(float[] lab)
Note this method will typically be called when converting a bitmap, and we have to map from- Specified by:
toCIEXYZ
in classColorSpace
-
getColor
public static Color getColor(float L, float a, float b)
Get a Color in the standard CIELAB D50 ColorSpace, based on the D50 illuminant. This is usually the correct method to get a Lab color for use as an alternate for aSpotColorSpace
Spot color, for instance.- Parameters:
L
- the "L" value, which will be clipped to the range 0..100a
- the "a" value, which will be clipped to the range -100..100b
- the "b" value, which will be clipped to the range -100..100
-
getColor
public static Color getColor(float L, float a, float b, float alpha)
Get a Color in the standard CIELAB D50 ColorSpace, based on the D50 illuminant. This is usually the correct method to get a Lab color for use as an alternate for aSpotColorSpace
Spot color, for instance.- Parameters:
L
- the "L" value, which will be clipped to the range 0..100a
- the "a" value, which will be clipped to the range -100..100b
- the "b" value, which will be clipped to the range -100..100alpha
- the alpha value from 0..1
-
getColorD65
public static Color getColorD65(float L, float a, float b)
Get a Color in the CIELAB ColorSpace, based on the D65 illuminant.- Parameters:
L
- the "L" value, which will be clipped to the range 0..100a
- the "a" value, which will be clipped to the range -100..100b
- the "b" value, which will be clipped to the range -100..100
-
convertGradient
public static List<Map.Entry<Float,Color>> convertGradient(List<Map.Entry<Float,Color>> in, ColorSpace target, ColorSpace interpolation, String options)
Given a list of [Fraction,Color] pairs in one (or more) ColorSpaces representing a Gradient, return a List representing the same gradient in the specified target ColorSpace, ensuring that each Color is within the specified tolerance. The colors will be interpolated in the specified interpolation ColorSpace, which may be null - if it is, the interpolation ColorSpace is the ColorSpace of the supplied colors, or CIELab if they're in multiple ColorSpaces. The tolerance is the maximum CIE94 delta-E allowable. This method is definitely not for general use.- Parameters:
in
- the list of [t, color] pairs, where t is a value from 0..1 indicating the location in the gradient, and color is the color at that point. The "t" values must be strictly ascending.target
- the target ColorSpace which all the colors will be converted to, or null to choose an appropriate space supported in PDFinterpolation
- the ColorSpace which the interpolation will take place in, or null to derive as described above.options
- options to control the process.- Since:
- 2.24.1
-
-