Class PDSeparation
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
-
- org.apache.pdfbox.pdmodel.graphics.color.PDSpecialColorSpace
-
- org.apache.pdfbox.pdmodel.graphics.color.PDSeparation
-
- All Implemented Interfaces:
COSObjectable
public class PDSeparation extends PDSpecialColorSpace
A Separation color space used to specify either additional colorants or for isolating the control of individual colour components of a device colour space for a subtractive device. When such a space is the current colour space, the current colour shall be a single-component value, called a tint, that controls the given colorant or colour components only.
-
-
Field Summary
Fields Modifier and Type Field Description private static int
ALTERNATE_CS
private PDColorSpace
alternateColorSpace
private static int
COLORANT_NAMES
private PDColor
initialColor
private static int
TINT_TRANSFORM
private PDFunction
tintTransform
private java.util.Map<java.lang.Integer,float[]>
toRGBMap
Map used to speed uptoRGB(float[])
.-
Fields inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
array
-
-
Constructor Summary
Constructors Constructor Description PDSeparation()
Creates a new Separation color space.PDSeparation(COSArray separation)
Creates a new Separation color space from a PDF color space array.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PDColorSpace
getAlternateColorSpace()
Returns the colorant name.java.lang.String
getColorantName()
Returns the colorant name.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 spacevoid
setAlternateColorSpace(PDColorSpace colorSpace)
Sets the alternate color space.void
setColorantName(java.lang.String name)
Sets the colorant name.void
setTintTransform(PDFunction tint)
Sets the tint transform function.protected void
tintTransform(float[] samples, int[] alt)
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 java.awt.image.BufferedImage
toRGBImage2(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
-
initialColor
private final PDColor initialColor
-
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
-
alternateColorSpace
private PDColorSpace alternateColorSpace
-
tintTransform
private PDFunction tintTransform
-
toRGBMap
private java.util.Map<java.lang.Integer,float[]> toRGBMap
Map used to speed uptoRGB(float[])
. Note that this class contains three maps (this and the two intoRGBImage(java.awt.image.WritableRaster)
andtoRGBImage2(java.awt.image.WritableRaster)
. The maps use different key intervals. This map here is needed for shading, which produce more than 256 different float values, which we cast to int so that the map can work.
-
-
Constructor Detail
-
PDSeparation
public PDSeparation()
Creates a new Separation color space.
-
PDSeparation
public PDSeparation(COSArray separation) throws java.io.IOException
Creates a new Separation color space from a PDF color space array.- Parameters:
separation
- an array containing all separation information.- Throws:
java.io.IOException
- if the color space or the function could not be created.
-
-
Method Detail
-
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
-
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
-
toRGBImage2
private java.awt.image.BufferedImage toRGBImage2(java.awt.image.WritableRaster raster) throws java.io.IOException
- Throws:
java.io.IOException
-
tintTransform
protected void tintTransform(float[] samples, int[] alt) 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.
-
getAlternateColorSpace
public PDColorSpace getAlternateColorSpace()
Returns the colorant name.- Returns:
- the name of the colorant
-
getColorantName
public java.lang.String getColorantName()
Returns the colorant name.- Returns:
- the name of the colorant
-
setColorantName
public void setColorantName(java.lang.String name)
Sets the colorant name.- Parameters:
name
- the name of the colorant
-
setAlternateColorSpace
public void setAlternateColorSpace(PDColorSpace colorSpace)
Sets the alternate color space.- Parameters:
colorSpace
- The alternate color space.
-
setTintTransform
public void setTintTransform(PDFunction tint)
Sets the tint transform function.- Parameters:
tint
- the tint transform function
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-