Package org.faceless.pdf2
Class CMYKColorSpace
- java.lang.Object
-
- java.awt.color.ColorSpace
-
- org.faceless.pdf2.CMYKColorSpace
-
- All Implemented Interfaces:
java.io.Serializable
public class CMYKColorSpace extends java.awt.color.ColorSpace
A subclass of
ColorSpace
representing the uncalibrated (device-dependent) CMYK color space available in PDF documents.If colors need to be specified in CMYK, but device-independent color (the kind available with an ICC Profile) is not required, this ColorSpace should be used, as it doesn't require an ICC profile to be embedded in the PDF (resulting in a much smaller file). For some subsets of PDF (specifically
PDF/X
), RGB colors are not allowed, so anyone creating documents for that profile will probably make heavy use of this colorspace.Typically this class will be used as follows:
Color cyan = CMYKColorSpace.getColor(1, 0, 0, 0);
Conversion to/from RGB
When rendering PDFs containing CMYK images or graphics to RGB, the characteristics of this space become important. The CMYKColorSpace prior to version 2.28.3 was suitable for conversion from CMYK to RGB, but not the reverse. As version 2.28.3 introduced a CMYK workflow, the default CMYK profile had to change too, and now defaults to a a fast approximation of the FOGRA39 perceptual intent, but this can be changed by setting the System propertyorg.faceless.pdf2.DeviceCMYK
to one of the following options:legacy The generic CMYK profile used with the PDF Library prior to 2.28.3 swop A fast approximation of US Web Coated (SWOP) v2 fogra A fast approximation of Coated FOGRA39 from ISO12647-2:2004 - See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.awt.Color
BLACK
A convenient constant that represents the color black in the uncalibrated CMYK colorspacestatic java.awt.Color
BLACK0
A convenient constant that represents the color black in the uncalibated Grayscale colorspacestatic java.awt.Color
WHITE
A convenient constant that represents the color white in the uncalibrated CMYK colorspacestatic java.awt.Color
WHITE0
A convenient constant that represents the color black in the uncalibated Grayscale colorspace-
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 float[]
fromCIEXYZ(float[] xyz)
float[]
fromRGB(float[] rgb)
static java.awt.Color
getColor(float c, float m, float y, float k)
A convenience method, returning an opaque color in the CMYK colorspace with the specified levels of cyan, magenta, yellow and black.static java.awt.Color
getColor(float c, float m, float y, float k, float a)
A convenience method, returning a color in the CMYK colorspace with the specified levels of cyan, magenta, yellow and black, and the specified alpha value.static CMYKColorSpace
getInstance()
static CMYKColorSpace
getInstance(java.lang.String name)
java.lang.String
getName(int i)
float[]
toCIEXYZ(float[] cmyk)
float[]
toRGB(float[] cmyk)
int[]
toRGB(int[] cmyk, int[] rgb, int intent)
java.lang.String
toString()
-
-
-
Field Detail
-
BLACK
public static final java.awt.Color BLACK
A convenient constant that represents the color black in the uncalibrated CMYK colorspace
-
BLACK0
public static final java.awt.Color BLACK0
A convenient constant that represents the color black in the uncalibated Grayscale colorspace- Since:
- 2.23.1
-
WHITE0
public static final java.awt.Color WHITE0
A convenient constant that represents the color black in the uncalibated Grayscale colorspace- Since:
- 2.23.1
-
WHITE
public static final java.awt.Color WHITE
A convenient constant that represents the color white in the uncalibrated CMYK colorspace
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toRGB
public float[] toRGB(float[] cmyk)
- Specified by:
toRGB
in classjava.awt.color.ColorSpace
-
toCIEXYZ
public float[] toCIEXYZ(float[] cmyk)
- Specified by:
toCIEXYZ
in classjava.awt.color.ColorSpace
-
fromRGB
public float[] fromRGB(float[] rgb)
- Specified by:
fromRGB
in classjava.awt.color.ColorSpace
-
fromCIEXYZ
public float[] fromCIEXYZ(float[] xyz)
- Specified by:
fromCIEXYZ
in classjava.awt.color.ColorSpace
-
getName
public java.lang.String getName(int i)
- Overrides:
getName
in classjava.awt.color.ColorSpace
-
toRGB
public int[] toRGB(int[] cmyk, int[] rgb, int intent)
-
getInstance
public static CMYKColorSpace getInstance()
-
getInstance
public static CMYKColorSpace getInstance(java.lang.String name)
-
getColor
public static java.awt.Color getColor(float c, float m, float y, float k)
A convenience method, returning an opaque color in the CMYK colorspace with the specified levels of cyan, magenta, yellow and black. The parameters must be in the range from 0.0 to 1.0, or anIllegalArgumentException
is thrown- Parameters:
c
- the level of cyan from 0.0 to 1.0m
- the level of magenta from 0.0 to 1.0y
- the level of yellow from 0.0 to 1.0k
- the level of black from 0.0 to 1.0- Throws:
java.lang.IllegalArgumentException
- if any of the parameters are outside the renage0 <= n <= 1
-
getColor
public static java.awt.Color getColor(float c, float m, float y, float k, float a)
A convenience method, returning a color in the CMYK colorspace with the specified levels of cyan, magenta, yellow and black, and the specified alpha value. All the parameters must be in the range from 0.0 to 1.0, or anIllegalArgumentException
is thrown- Parameters:
c
- the level of cyan from 0.0 to 1.0m
- the level of magenta from 0.0 to 1.0y
- the level of yellow from 0.0 to 1.0k
- the level of black from 0.0 to 1.0a
- the alpha level to use - 0 is transparent, 1 is opaque.- Throws:
java.lang.IllegalArgumentException
- if any of the parameters are outside the renage0 <= n <= 1
-
-