Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.graphics.color

public final Class PDIndexed

extends PDSpecialColorSpace
Class Inheritance
Imports
java.awt.Point, java.awt.image.BufferedImage, .ColorModel, .DataBuffer, .IndexColorModel, .Raster, .WritableRaster, java.io.IOException, org.apache.pdfbox.cos.COSArray, .COSBase, .COSInteger, .COSName, .COSNumber, .COSStream, .COSString, org.apache.pdfbox.pdmodel.PDResources, org.apache.pdfbox.pdmodel.common.PDStream

An Indexed colour space specifies that an area is to be painted using a colour table of arbitrary colours from another color space.
Authors
John Hewson, Ben Litchfield

Field Summary

Modifier and TypeField and Description
private int
private PDColorSpace
private float[][]
private final PDColor
private byte[]
private int[][]

Constructor Summary

AccessConstructor and Description
public
PDIndexed()

Creates a new Indexed color space.

public
PDIndexed(COSArray
the array containing the indexed parameters
indexedArray
)

Creates a new indexed color space from the given PDF array.

public
PDIndexed(COSArray
the array containing the indexed parameters
indexedArray
,
PDResources
the resources, can be null. Allows to use its cache for the colorspace.
resources
)

Creates a new indexed color space from the given PDF array.

Method Summary

Modifier and TypeMethod and Description
public PDColorSpace

Returns:

the base color space.
getBaseColorSpace
()

Returns the base color space.

public float[]
getDefaultDecode(int
the number of bits per component.
bitsPerComponent
)

Implements abstract org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.getDefaultDecode.

Returns the default decode array for this color space.

private int
public PDColor
getInitialColor()

Implements abstract org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.getInitialColor.

Returns the initial color value for this color space.

public String
getName()

Implements abstract org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.getName.

Returns the name of the color space.

public int
getNumberOfComponents()

Implements abstract org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.getNumberOfComponents.

Returns the number of components in this color space

private void
private void
private void
public void
setBaseColorSpace(PDColorSpace
the base color space
base
)

Sets the base color space.

public void
setHighValue(int
the highest value for the lookup table
high
)

Sets the highest value that is allowed.

public BufferedImage
toRawImage(WritableRaster
the source raster
raster
)

Implements abstract org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.toRawImage.

Returns the image in this colorspace or null.

public float[]
toRGB(float[]
a color value with component values between 0 and 1
value
)

Implements abstract org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.toRGB.

Returns the RGB equivalent of the given color value.

public BufferedImage
toRGBImage(WritableRaster
the source raster
raster
)

Implements abstract org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.toRGBImage.

Returns the (A)RGB equivalent of the given raster.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Field Detail

actualMaxIndexback to summary
private int actualMaxIndex
baseColorSpaceback to summary
private PDColorSpace baseColorSpace
colorTableback to summary
private float[][] colorTable
initialColorback to summary
private final PDColor initialColor
lookupDataback to summary
private byte[] lookupData
rgbColorTableback to summary
private int[][] rgbColorTable

Constructor Detail

PDIndexedback to summary
public PDIndexed()

Creates a new Indexed color space. Default DeviceRGB, hival 255.

PDIndexedback to summary
public PDIndexed(COSArray indexedArray) throws IOException

Creates a new indexed color space from the given PDF array.

Parameters
indexedArray:COSArray

the array containing the indexed parameters

Exceptions
IOException:
if the colorspace could not be created
PDIndexedback to summary
public PDIndexed(COSArray indexedArray, PDResources resources) throws IOException

Creates a new indexed color space from the given PDF array.

Parameters
indexedArray:COSArray

the array containing the indexed parameters

resources:PDResources

the resources, can be null. Allows to use its cache for the colorspace.

Exceptions
IOException:
if the colorspace could not be created

Method Detail

getBaseColorSpaceback to summary
public PDColorSpace getBaseColorSpace()

Returns the base color space.

Returns:PDColorSpace

the base color space.

getDefaultDecodeback to summary
public float[] getDefaultDecode(int bitsPerComponent)

Implements abstract org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.getDefaultDecode.

Doc from org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.getDefaultDecode.

Returns the default decode array for this color space.

Parameters
bitsPerComponent:int

the number of bits per component.

Returns:float[]

the default decode array

Annotations
@Override
getHivalback to summary
private int getHival()
getInitialColorback to summary
public PDColor getInitialColor()

Implements abstract org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.getInitialColor.

Doc from org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.getInitialColor.

Returns the initial color value for this color space.

Returns:PDColor

the initial color value for this color space

Annotations
@Override
getNameback to summary
public String getName()

Implements abstract org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.getName.

Doc from org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.getName.

Returns the name of the color space.

Returns:String

the name of the color space

Annotations
@Override
getNumberOfComponentsback to summary
public int getNumberOfComponents()

Implements abstract org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.getNumberOfComponents.

Doc from org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.getNumberOfComponents.

Returns the number of components in this color space

Returns:int

the number of components in this color space

Annotations
@Override
initRgbColorTableback to summary
private void initRgbColorTable() throws IOException
readColorTableback to summary
private void readColorTable() throws IOException
readLookupDataback to summary
private void readLookupData() throws IOException
setBaseColorSpaceback to summary
public void setBaseColorSpace(PDColorSpace base)

Sets the base color space.

Parameters
base:PDColorSpace

the base color space

setHighValueback to summary
public void setHighValue(int high)

Sets the highest value that is allowed. This cannot be higher than 255.

Parameters
high:int

the highest value for the lookup table

toRawImageback to summary
public BufferedImage toRawImage(WritableRaster raster)

Implements abstract org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.toRawImage.

Doc from org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.toRawImage.

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 to toRGBImage(WritableRaster) if this returns null.

Parameters
raster:WritableRaster

the source raster

Returns:BufferedImage

an buffered image in this colorspace. Or null if it is not possible to extract that image with the original colorspace without conversion.

Annotations
@Override
toRGBback to summary
public float[] toRGB(float[] value)

Implements abstract org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.toRGB.

Doc from org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.toRGB.

Returns the RGB equivalent of the given color value.

Parameters
value:float[]

a color value with component values between 0 and 1

Returns:float[]

an array of R,G,B value between 0 and 255

Annotations
@Override
toRGBImageback to summary
public BufferedImage toRGBImage(WritableRaster raster) throws IOException

Implements abstract org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.toRGBImage.

Doc from org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace.toRGBImage.

Returns the (A)RGB equivalent of the given raster.

Parameters
raster:WritableRaster

the source raster

Returns:BufferedImage

an (A)RGB buffered image

Annotations
@Override
Exceptions
IOException:
if the color conversion fails
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override