Class PDIndexed
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
-
- org.apache.pdfbox.pdmodel.graphics.color.PDSpecialColorSpace
-
- org.apache.pdfbox.pdmodel.graphics.color.PDIndexed
-
- All Implemented Interfaces:
COSObjectable
public final class PDIndexed extends PDSpecialColorSpace
An Indexed colour space specifies that an area is to be painted using a colour table of arbitrary colours from another color space.
-
-
Field Summary
Fields Modifier and Type Field Description private intactualMaxIndexprivate PDColorSpacebaseColorSpaceprivate float[][]colorTableprivate PDColorinitialColorprivate byte[]lookupDataprivate int[][]rgbColorTable-
Fields inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
array
-
-
Constructor Summary
Constructors Constructor Description PDIndexed()Creates a new Indexed color space.PDIndexed(COSArray indexedArray)Creates a new indexed color space from the given PDF array.PDIndexed(COSArray indexedArray, PDResources resources)Creates a new indexed color space from the given PDF array.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PDColorSpacegetBaseColorSpace()Returns the base color space.float[]getDefaultDecode(int bitsPerComponent)Returns the default decode array for this color space.private intgetHival()PDColorgetInitialColor()Returns the initial color value for this color space.java.lang.StringgetName()Returns the name of the color space.intgetNumberOfComponents()Returns the number of components in this color spaceprivate voidinitRgbColorTable()private voidreadColorTable()private voidreadLookupData()voidsetBaseColorSpace(PDColorSpace base)Sets the base color space.voidsetHighValue(int high)Sets the highest value that is allowed.java.awt.image.BufferedImagetoRawImage(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.BufferedImagetoRGBImage(java.awt.image.WritableRaster raster)Returns the (A)RGB equivalent of the given raster.java.lang.StringtoString()-
Methods inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
create, create, create, getCOSObject, toRawImage, toRGBImageAWT
-
-
-
-
Field Detail
-
initialColor
private final PDColor initialColor
-
baseColorSpace
private PDColorSpace baseColorSpace
-
lookupData
private byte[] lookupData
-
colorTable
private float[][] colorTable
-
actualMaxIndex
private int actualMaxIndex
-
rgbColorTable
private int[][] rgbColorTable
-
-
Constructor Detail
-
PDIndexed
public PDIndexed()
Creates a new Indexed color space. Default DeviceRGB, hival 255.
-
PDIndexed
public PDIndexed(COSArray indexedArray) throws java.io.IOException
Creates a new indexed color space from the given PDF array.- Parameters:
indexedArray- the array containing the indexed parameters- Throws:
java.io.IOException- if the colorspace could not be created
-
PDIndexed
public PDIndexed(COSArray indexedArray, PDResources resources) throws java.io.IOException
Creates a new indexed color space from the given PDF array.- Parameters:
indexedArray- the array containing the indexed parametersresources- the resources, can be null. Allows to use its cache for the colorspace.- Throws:
java.io.IOException- if the colorspace could not be created
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from class:PDColorSpaceReturns the name of the color space.- Specified by:
getNamein classPDColorSpace- Returns:
- the name of the color space
-
getNumberOfComponents
public int getNumberOfComponents()
Description copied from class:PDColorSpaceReturns the number of components in this color space- Specified by:
getNumberOfComponentsin classPDColorSpace- Returns:
- the number of components in this color space
-
getDefaultDecode
public float[] getDefaultDecode(int bitsPerComponent)
Description copied from class:PDColorSpaceReturns the default decode array for this color space.- Specified by:
getDefaultDecodein classPDColorSpace- Parameters:
bitsPerComponent- the number of bits per component.- Returns:
- the default decode array
-
getInitialColor
public PDColor getInitialColor()
Description copied from class:PDColorSpaceReturns the initial color value for this color space.- Specified by:
getInitialColorin classPDColorSpace- Returns:
- the initial color value for this color space
-
initRgbColorTable
private void initRgbColorTable() throws java.io.IOException- Throws:
java.io.IOException
-
toRGB
public float[] toRGB(float[] value)
Description copied from class:PDColorSpaceReturns the RGB equivalent of the given color value.- Specified by:
toRGBin 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
-
toRGBImage
public java.awt.image.BufferedImage toRGBImage(java.awt.image.WritableRaster raster) throws java.io.IOExceptionDescription copied from class:PDColorSpaceReturns the (A)RGB equivalent of the given raster.- Specified by:
toRGBImagein classPDColorSpace- Parameters:
raster- the source raster- Returns:
- an (A)RGB buffered image
- Throws:
java.io.IOException- if the color conversion fails
-
toRawImage
public java.awt.image.BufferedImage toRawImage(java.awt.image.WritableRaster raster)
Description copied from class:PDColorSpaceReturns 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:
toRawImagein 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.
-
getBaseColorSpace
public PDColorSpace getBaseColorSpace()
Returns the base color space.- Returns:
- the base color space.
-
getHival
private int getHival()
-
readLookupData
private void readLookupData() throws java.io.IOException- Throws:
java.io.IOException
-
readColorTable
private void readColorTable() throws java.io.IOException- Throws:
java.io.IOException
-
setBaseColorSpace
public void setBaseColorSpace(PDColorSpace base)
Sets the base color space.- Parameters:
base- the base color space
-
setHighValue
public void setHighValue(int high)
Sets the highest value that is allowed. This cannot be higher than 255.- Parameters:
high- the highest value for the lookup table
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-