Class PDDeviceCMYK
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
-
- org.apache.pdfbox.pdmodel.graphics.color.PDDeviceColorSpace
-
- org.apache.pdfbox.pdmodel.graphics.color.PDDeviceCMYK
-
- All Implemented Interfaces:
COSObjectable
public class PDDeviceCMYK extends PDDeviceColorSpace
Allows colors to be specified according to the subtractive CMYK (cyan, magenta, yellow, black) model typical of printers and other paper-based output devices.
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.color.ICC_ColorSpace
awtColorSpace
private PDColor
initialColor
static PDDeviceCMYK
INSTANCE
The single instance of this class.private boolean
usePureJavaCMYKConversion
-
Fields inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
array
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PDDeviceCMYK()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description float[]
getDefaultDecode(int bitsPerComponent)
Returns the default decode array for this color space.protected java.awt.color.ICC_Profile
getICCProfile()
PDColor
getInitialColor()
Returns the initial color value for this color space.java.lang.String
getName()
Returns the name of the color space.int
getNumberOfComponents()
Returns the number of components in this color spaceprotected void
init()
Lazy load the ICC profile, because it's slow.java.awt.image.BufferedImage
toRawImage(java.awt.image.WritableRaster raster)
Returns the image in this colorspace or null.float[]
toRGB(float[] value)
Returns the RGB equivalent of the given color value.java.awt.image.BufferedImage
toRGBImage(java.awt.image.WritableRaster raster)
Returns the (A)RGB equivalent of the given raster.protected java.awt.image.BufferedImage
toRGBImageAWT(java.awt.image.WritableRaster raster, java.awt.color.ColorSpace colorSpace)
Returns the (A)RGB equivalent of the given raster, using the given AWT color space to perform the conversion.-
Methods inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDDeviceColorSpace
getCOSObject, toString
-
Methods inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
create, create, create, toRawImage
-
-
-
-
Field Detail
-
INSTANCE
public static PDDeviceCMYK INSTANCE
The single instance of this class.
-
initialColor
private final PDColor initialColor
-
awtColorSpace
private volatile java.awt.color.ICC_ColorSpace awtColorSpace
-
usePureJavaCMYKConversion
private boolean usePureJavaCMYKConversion
-
-
Method Detail
-
init
protected void init() throws java.io.IOException
Lazy load the ICC profile, because it's slow.- Throws:
java.io.IOException
-
getICCProfile
protected java.awt.color.ICC_Profile getICCProfile() throws java.io.IOException
- Throws:
java.io.IOException
-
getName
public java.lang.String getName()
Description copied from class:PDColorSpace
Returns the name of the color space.- Specified by:
getName
in classPDColorSpace
- Returns:
- the name of the color space
-
getNumberOfComponents
public int getNumberOfComponents()
Description copied from class:PDColorSpace
Returns the number of components in this color space- Specified by:
getNumberOfComponents
in classPDColorSpace
- Returns:
- the number of components in this color space
-
getDefaultDecode
public float[] getDefaultDecode(int bitsPerComponent)
Description copied from class:PDColorSpace
Returns the default decode array for this color space.- Specified by:
getDefaultDecode
in classPDColorSpace
- Parameters:
bitsPerComponent
- the number of bits per component.- Returns:
- the default decode array
-
getInitialColor
public PDColor getInitialColor()
Description copied from class:PDColorSpace
Returns the initial color value for this color space.- Specified by:
getInitialColor
in classPDColorSpace
- Returns:
- the initial color value for this color space
-
toRGB
public float[] toRGB(float[] value) throws java.io.IOException
Description copied from class:PDColorSpace
Returns the RGB equivalent of the given color value.- Specified by:
toRGB
in classPDColorSpace
- Parameters:
value
- a color value with component values between 0 and 1- Returns:
- an array of R,G,B value between 0 and 255
- Throws:
java.io.IOException
- if the color conversion fails
-
toRawImage
public java.awt.image.BufferedImage toRawImage(java.awt.image.WritableRaster raster) throws java.io.IOException
Description copied from class:PDColorSpace
Returns the image in this colorspace or null. No conversion is performed. For special colorspaces like PDSeparation the image is returned in the gray colorspace. For undefined colorspaces like DeviceCMYK/DeviceRGB and DeviceGray null is returned. You can always fallback toPDColorSpace.toRGBImage(WritableRaster)
if this returns null.- Specified by:
toRawImage
in classPDColorSpace
- Parameters:
raster
- the source raster- Returns:
- an buffered image in this colorspace. Or null if it is not possible to extract that image with the original colorspace without conversion.
- Throws:
java.io.IOException
-
toRGBImage
public java.awt.image.BufferedImage toRGBImage(java.awt.image.WritableRaster raster) throws java.io.IOException
Description copied from class:PDColorSpace
Returns the (A)RGB equivalent of the given raster.- Specified by:
toRGBImage
in classPDColorSpace
- Parameters:
raster
- the source raster- Returns:
- an (A)RGB buffered image
- Throws:
java.io.IOException
- if the color conversion fails
-
toRGBImageAWT
protected java.awt.image.BufferedImage toRGBImageAWT(java.awt.image.WritableRaster raster, java.awt.color.ColorSpace colorSpace)
Description copied from class:PDColorSpace
Returns the (A)RGB equivalent of the given raster, using the given AWT color space to perform the conversion.- Overrides:
toRGBImageAWT
in classPDColorSpace
- Parameters:
raster
- the source rastercolorSpace
- the AWT- Returns:
- an (A)RGB buffered image
-
-