Class PDDeviceN
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
-
- org.apache.pdfbox.pdmodel.graphics.color.PDSpecialColorSpace
-
- org.apache.pdfbox.pdmodel.graphics.color.PDDeviceN
-
- All Implemented Interfaces:
COSObjectable
public class PDDeviceN extends PDSpecialColorSpace
DeviceN colour spaces may contain an arbitrary number of colour components. DeviceN represents a colour space containing multiple components that correspond to colorants of some target device. As with Separation colour spaces, readers are able to approximate the colorants if they are not available on the current output device, such as a display
-
-
Field Summary
Fields Modifier and Type Field Description private static int
ALTERNATE_CS
private PDColorSpace
alternateColorSpace
private PDDeviceNAttributes
attributes
private static int
COLORANT_NAMES
private int[]
colorantToComponent
private static int
DEVICEN_ATTRIBUTES
private PDColor
initialColor
private int
numColorants
private PDColorSpace
processColorSpace
private PDSeparation[]
spotColorSpaces
private static int
TINT_TRANSFORM
private PDFunction
tintTransform
-
Fields inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
array
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PDColorSpace
getAlternateColorSpace()
This will get the alternate color space for this separation.PDDeviceNAttributes
getAttributes()
Returns the attributes associated with the DeviceN color space.java.util.List<java.lang.String>
getColorantNames()
Returns the list of colorants.float[]
getDefaultDecode(int bitsPerComponent)
Returns the default decode array for this color space.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 spacePDFunction
getTintTransform()
This will get the tint transform function.private void
initColorConversionCache()
boolean
isNChannel()
Returns true if this color space has the NChannel subtype.void
setAlternateColorSpace(PDColorSpace cs)
This will set the alternate color space.void
setAttributes(PDDeviceNAttributes attributes)
Sets the color space attributes.void
setColorantNames(java.util.List<java.lang.String> names)
Sets the list of colorantsvoid
setTintTransform(PDFunction tint)
This will set the tint transform function.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.private float[]
toRGBWithAttributes(float[] value)
private java.awt.image.BufferedImage
toRGBWithAttributes(java.awt.image.WritableRaster raster)
private float[]
toRGBWithTintTransform(float[] value)
private java.awt.image.BufferedImage
toRGBWithTintTransform(java.awt.image.WritableRaster raster)
java.lang.String
toString()
-
Methods inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDSpecialColorSpace
getCOSObject
-
Methods inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
create, create, create, toRawImage, toRGBImageAWT
-
-
-
-
Field Detail
-
COLORANT_NAMES
private static final int COLORANT_NAMES
- See Also:
- Constant Field Values
-
ALTERNATE_CS
private static final int ALTERNATE_CS
- See Also:
- Constant Field Values
-
TINT_TRANSFORM
private static final int TINT_TRANSFORM
- See Also:
- Constant Field Values
-
DEVICEN_ATTRIBUTES
private static final int DEVICEN_ATTRIBUTES
- See Also:
- Constant Field Values
-
alternateColorSpace
private PDColorSpace alternateColorSpace
-
tintTransform
private PDFunction tintTransform
-
attributes
private PDDeviceNAttributes attributes
-
initialColor
private PDColor initialColor
-
numColorants
private int numColorants
-
colorantToComponent
private int[] colorantToComponent
-
processColorSpace
private PDColorSpace processColorSpace
-
spotColorSpaces
private PDSeparation[] spotColorSpaces
-
-
Constructor Detail
-
PDDeviceN
public PDDeviceN()
Creates a new DeviceN color space.
-
PDDeviceN
public PDDeviceN(COSArray deviceN) throws java.io.IOException
Creates a new DeviceN color space from the given COS array.- Parameters:
deviceN
- an array containing the color space information- Throws:
java.io.IOException
-
-
Method Detail
-
initColorConversionCache
private void initColorConversionCache() throws java.io.IOException
- 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
-
toRGBWithAttributes
private java.awt.image.BufferedImage toRGBWithAttributes(java.awt.image.WritableRaster raster) throws java.io.IOException
- Throws:
java.io.IOException
-
toRGBWithTintTransform
private java.awt.image.BufferedImage toRGBWithTintTransform(java.awt.image.WritableRaster raster) throws java.io.IOException
- Throws:
java.io.IOException
-
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
-
toRGBWithAttributes
private float[] toRGBWithAttributes(float[] value) throws java.io.IOException
- Throws:
java.io.IOException
-
toRGBWithTintTransform
private float[] toRGBWithTintTransform(float[] value) throws java.io.IOException
- Throws:
java.io.IOException
-
toRawImage
public java.awt.image.BufferedImage toRawImage(java.awt.image.WritableRaster raster)
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.
-
isNChannel
public boolean isNChannel()
Returns true if this color space has the NChannel subtype.- Returns:
- true if subtype is NChannel
-
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 final 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
-
getColorantNames
public java.util.List<java.lang.String> getColorantNames()
Returns the list of colorants.- Returns:
- the list of colorants
-
getAttributes
public PDDeviceNAttributes getAttributes()
Returns the attributes associated with the DeviceN color space.- Returns:
- the DeviceN attributes
-
setColorantNames
public void setColorantNames(java.util.List<java.lang.String> names)
Sets the list of colorants- Parameters:
names
- the list of colorants
-
setAttributes
public void setAttributes(PDDeviceNAttributes attributes)
Sets the color space attributes. If null is passed in then all attribute will be removed.- Parameters:
attributes
- the color space attributes, or null
-
getAlternateColorSpace
public PDColorSpace getAlternateColorSpace() throws java.io.IOException
This will get the alternate color space for this separation.- Returns:
- The alternate color space.
- Throws:
java.io.IOException
- If there is an error getting the alternate color space.
-
setAlternateColorSpace
public void setAlternateColorSpace(PDColorSpace cs)
This will set the alternate color space.- Parameters:
cs
- The alternate color space.
-
getTintTransform
public PDFunction getTintTransform() throws java.io.IOException
This will get the tint transform function.- Returns:
- The tint transform function.
- Throws:
java.io.IOException
- if there is an error creating the function.
-
setTintTransform
public void setTintTransform(PDFunction tint)
This will set the tint transform function.- Parameters:
tint
- The tint transform function.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-