Class PDICCBased
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
-
- org.apache.pdfbox.pdmodel.graphics.color.PDCIEBasedColorSpace
-
- org.apache.pdfbox.pdmodel.graphics.color.PDICCBased
-
- All Implemented Interfaces:
COSObjectable
public final class PDICCBased extends PDCIEBasedColorSpace
ICCBased color spaces are based on a cross-platform color profile as defined by the International Color Consortium (ICC).- Author:
- Ben Litchfield, John Hewson
-
-
Field Summary
-
Fields inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
array
-
-
Constructor Summary
Constructors Constructor Description PDICCBased(COSArray iccArray)
Creates a new ICC color space using the PDF array.PDICCBased(PDDocument doc)
Creates a new ICC color space with an empty stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description PDColorSpace
getAlternateColorSpace()
Returns a list of alternate color spaces for non-conforming readers.int
getColorSpaceType()
Returns the type of the color space in the ICC profile.float[]
getDefaultDecode(int bitsPerComponent)
Returns the default decode array for this color space.PDColor
getInitialColor()
Returns the initial color value for this color space.COSStream
getMetadata()
Returns the metadata stream for this object, or null if there is no metadata stream.java.lang.String
getName()
Returns the name of the color space.int
getNumberOfComponents()
Returns the number of components in this color spacePDStream
getPDStream()
Get the underlying ICC profile stream.PDRange
getRangeForComponent(int n)
Returns the range for a certain component number.void
setAlternateColorSpaces(java.util.List<PDColorSpace> list)
Sets the list of alternateColorSpace color spaces.void
setMetadata(COSStream metadata)
Sets the metadata stream that is associated with this color space.void
setNumberOfComponents(int n)
Deprecated.void
setRangeForComponent(PDRange range, int n)
Sets the range for this color space.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.java.lang.String
toString()
-
Methods inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
create, create, create, getCOSObject, toRGBImageAWT
-
-
-
-
Constructor Detail
-
PDICCBased
public PDICCBased(PDDocument doc)
Creates a new ICC color space with an empty stream.- Parameters:
doc
- the document to store the ICC data
-
PDICCBased
public PDICCBased(COSArray iccArray) throws java.io.IOException
Creates a new ICC color space using the PDF array.- Parameters:
iccArray
- the ICC stream object- Throws:
java.io.IOException
- if there is an error reading the ICC profile or if the parameter is invalid.
-
-
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
-
getPDStream
public PDStream getPDStream()
Get the underlying ICC profile stream.- Returns:
- the underlying ICC profile stream
-
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.- Overrides:
toRGBImage
in classPDCIEBasedColorSpace
- Parameters:
raster
- the source raster- Returns:
- an (A)RGB buffered image
- Throws:
java.io.IOException
- if the color conversion fails
-
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
-
getAlternateColorSpace
public PDColorSpace getAlternateColorSpace() throws java.io.IOException
Returns a list of alternate color spaces for non-conforming readers. WARNING: Do not use the information in a conforming reader.- Returns:
- A list of alternateColorSpace color spaces.
- Throws:
java.io.IOException
- If there is an error getting the alternateColorSpace color spaces.
-
getRangeForComponent
public PDRange getRangeForComponent(int n)
Returns the range for a certain component number. This will never return null. If it is not present then the range 0..1 will be returned.- Parameters:
n
- the component number to get the range for- Returns:
- the range for this component
-
getMetadata
public COSStream getMetadata()
Returns the metadata stream for this object, or null if there is no metadata stream.- Returns:
- the metadata stream, or null if there is none
-
getColorSpaceType
public int getColorSpaceType()
Returns the type of the color space in the ICC profile. If the ICC profile is invalid, the type of the alternate colorspace is returned, which will be one ofTYPE_GRAY
,TYPE_RGB
,TYPE_CMYK
, or -1 if that one is invalid.- Returns:
- an ICC color space type. See
ColorSpace.getType()
and the static values ofColorSpace
for more details.
-
setNumberOfComponents
@Deprecated public void setNumberOfComponents(int n)
Deprecated.Sets the number of color components.- Parameters:
n
- the number of color components
-
setAlternateColorSpaces
public void setAlternateColorSpaces(java.util.List<PDColorSpace> list)
Sets the list of alternateColorSpace color spaces.- Parameters:
list
- the list of color space objects
-
setRangeForComponent
public void setRangeForComponent(PDRange range, int n)
Sets the range for this color space.- Parameters:
range
- the new range for the a componentn
- the component to set the range for
-
setMetadata
public void setMetadata(COSStream metadata)
Sets the metadata stream that is associated with this color space.- Parameters:
metadata
- the new metadata stream
-
toString
public java.lang.String toString()
- Overrides:
toString
in classPDCIEBasedColorSpace
-
-