org.apache.pdfbox.pdmodel.graphics.color

## 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.

Author:
  John Hewson, Ben Litchfield

### Field Summary

### Fields inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace

`array`

### Constructor Summary

Constructors
Constructor and Description
`PDIndexed()` Deprecated. This will be removed in 4.0. If you need it, please contact us.
`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 Static Methods Instance Methods Concrete Methods Deprecated Methods
`static PDIndexed` `create(PDColorSpace base, int hival, byte[] lookupData)` Factory method to create a new indexed color space.
`PDColorSpace` `getBaseColorSpace()` Returns the base color space.
`float[]` `getDefaultDecode(int bitsPerComponent)` Returns the default decode array for this color space.
`PDColor` `getInitialColor()` Returns the initial color value for this color space.
`String` `getName()` Returns the name of the color space.
`int` `getNumberOfComponents()` Returns the number of components in this color space
`void` `setBaseColorSpace(PDColorSpace base)` Deprecated. This will be removed in 4.0. If you need it, please contact us.
`void` `setHighValue(int high)` Deprecated. This will be removed in 4.0. If you need it, please contact us.
`BufferedImage` `toRawImage(WritableRaster raster)` Returns the image in this colorspace or null.
`float[]` `toRGB(float[] value)` Returns the RGB equivalent of the given color value.
`BufferedImage` `toRGBImage(WritableRaster raster)` Returns the (A)RGB equivalent of the given raster.
`String` `toString()`

### Methods inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace

`create, create, create, getCOSObject, toRawImage, toRGBImageAWT`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### PDIndexed

    @Deprecated
    public PDIndexed()

Deprecated. This will be removed in 4.0. If you need it, please contact us.
Creates a new Indexed color space. Default DeviceRGB, hival 255.

#### PDIndexed

    public PDIndexed(COSArray indexedArray)
              throws IOException

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

Parameters:
  `indexedArray` - the array containing the indexed parameters
Throws:
  `IOException` - if the colorspace could not be created

#### PDIndexed

    public PDIndexed(COSArray indexedArray,
                     PDResources resources)
              throws IOException

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

Parameters:
  `indexedArray` - the array containing the indexed parameters
  `resources` - the resources, can be null. Allows to use its cache for the colorspace.
Throws:
  `IOException` - if the colorspace could not be created

### Method Detail

#### create

    public static PDIndexed create(PDColorSpace base,
                                   int hival,
                                   byte[] lookupData)
                            throws IOException

Factory method to create a new indexed color space.

Parameters:
  `base` - base colorspace, mandantory has to be != null
  `hival` - maximum valid index value for lookup data
  `lookupData` - array for lookup data, mandantory has to be != null
Returns:
  an instance of PDIndedex initialized with the given values
Throws:
  `IOException` - if the colorspace could not be created

#### getName

    public String getName()

Description copied from class: `PDColorSpace`
Returns the name of the color space.

Specified by:
  `getName` in class `PDColorSpace`
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 class `PDColorSpace`
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 class `PDColorSpace`
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 class `PDColorSpace`
Returns:
  the initial color value for this color space

#### toRGB

    public float[] toRGB(float[] value)

Description copied from class: `PDColorSpace`
Returns the RGB equivalent of the given color value.

Specified by:
  `toRGB` in class `PDColorSpace`
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 BufferedImage toRGBImage(WritableRaster raster)
                             throws IOException

Description copied from class: `PDColorSpace`
Returns the (A)RGB equivalent of the given raster.

Specified by:
  `toRGBImage` in class `PDColorSpace`
Parameters:
  `raster` - the source raster
Returns:
  an (A)RGB buffered image
Throws:
  `IOException` - if the color conversion fails

#### toRawImage

    public BufferedImage toRawImage(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 to `PDColorSpace.toRGBImage(WritableRaster)` if this returns null.

Specified by:
  `toRawImage` in class `PDColorSpace`
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.

#### setBaseColorSpace

    @Deprecated
    public void setBaseColorSpace(PDColorSpace base)

Deprecated. This will be removed in 4.0. If you need it, please contact us.
Sets the base color space.

Parameters:
  `base` - the base color space

#### setHighValue

    @Deprecated
    public void setHighValue(int high)

Deprecated. This will be removed in 4.0. If you need it, please contact us.
Sets the highest value that is allowed. This cannot be higher than 255.

Parameters:
  `high` - the highest value for the lookup table

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`