# IndexedColorSpace Class

> Indexed color spaces are used to reduce the amount of memory used for processing images.

- Product: Adobe PDF Library 21
- Language: Modern C++
- Version: 21.4.0
- HTML page: https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/IndexedColorSpace
- Version index: https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/llms.txt

```cpp
class IndexedColorSpace : ColorSpace
```

**Namespace:** `datalogics_interface`

**Inherits from:** [`ColorSpace`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/ColorSpace.md)

## Description

Indexed color spaces are used to reduce the amount of memory used for processing images.

Indexed color spaces are used when a limited number of colors are needed.

Commonly, an image with an indexed color space can be one third the size of the same image with a standard color space, because the indexed image uses a smaller palette of colors.

**Uses types:** [`ColorSpace`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/ColorSpace.md), [`PDFObject`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFObject.md)

## Constructors

### IndexedColorSpace

```cpp
datalogics_interface::IndexedColorSpace::IndexedColorSpace(const ColorSpace &base, long hival, const std::vector< long > &lookup)
```

*constructor*

**Parameters**

- `base` ([`const ColorSpace &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/ColorSpace.md)): The base color space in which the values in the color table are to be interpreted. It can be any device or CIE-based color space or (in PDF 1.3) a Separation or DeviceN space, but not a Pattern space or another Indexed space.
- `hival` (`long`): an integer that specifies the maximum valid index value. In other words, the color table is to be indexed by integers in the range 0 to hival. hival can be no greater than 255.
- `lookup` (`const std::vector< long > &`): a list of integers in the range 0..255. There must be m * (hival + 1) values, where m is the number of components of the base color space.

Create a Indexed color space.

## Methods

### get_base

```cpp
std::unique_ptr< ColorSpace > datalogics_interface::IndexedColorSpace::get_base() const
```

**Returns:** [`std::unique_ptr< ColorSpace >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/ColorSpace.md)

The base color space in which the values in the color table are to be interpreted. It can be any device or CIE-based color space or (in PDF 1.3) a Separation or DeviceN space, but not a Pattern space or another Indexed space.

### get_hival

```cpp
long datalogics_interface::IndexedColorSpace::get_hival() const
```

**Returns:** `long`

an integer that specifies the maximum valid index value. In other words, the color table is to be indexed by integers in the range 0 to hival. hival can be no greater than 255.

### get_lookup

```cpp
std::vector< long > datalogics_interface::IndexedColorSpace::get_lookup() const
```

**Returns:** `std::vector< long >`

A list of integers in the range 0..255. There must be m * (hival + 1) values, where m is the number of components of the base color space.

### get_name

```cpp
std::string datalogics_interface::ColorSpace::get_name() const
```

**Returns:** `std::string`

The name of the color space. A named color space may be named something like DeviceRGB. More complicated color spaces may have a name like Indexed or ICCBased.

### get_num_components

```cpp
int datalogics_interface::ColorSpace::get_num_components() const
```

**Returns:** `int`

The number of color components.

The number of components in the color space.

For example, DeviceGray has 1 component, DeviceRGB has 3, and DeviceCMYK has 4.

### get_pdf_object

```cpp
std::unique_ptr< PDFObject > datalogics_interface::ColorSpace::get_pdf_object() const
```

**Returns:** [`std::unique_ptr< PDFObject >`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/PDFObject.md)

The PDFObject associated with the color space.

Get the PDFObject associated with the color space. This may be a PDFName, PDFDict, PDFStream, or PDFArray.

### operator==

```cpp
virtual bool datalogics_interface::ColorSpace::operator==(const ColorSpace &other) const
```

**Parameters**

- `other` ([`const ColorSpace &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/ColorSpace.md)): The ColorSpace to compare against.

**Returns:** `bool`

true if the two color spaces are equal, false otherwise.

Test for equality.

This works best for named color spaces.

More complex color spaces (such as ICCBased) do not support equality testing and will always return false.

### to_string

```cpp
std::string datalogics_interface::ColorSpace::to_string() const
```

**Returns:** `std::string`

A string describing this ColorSpace.

Convert a ColorSpace to a string representation.
