# NamedColorSpace Class

> Class used to define the color space in use.

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

```cpp
class NamedColorSpace : ColorSpace
```

**Namespace:** `datalogics_interface`

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

## Description

Class used to define the color space in use.

**Referenced by:** [`NamedColorSpace`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/NamedColorSpace.md)

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

## Constructors

### NamedColorSpace

```cpp
datalogics_interface::NamedColorSpace::NamedColorSpace(const std::string &name)
```

*constructor*

**Parameters**

- `name` (`const std::string &`): the name of the color space.

Create a named color space with the given name, e.g. DeviceRGB

## Methods

### device_cmyk

```cpp
static NamedColorSpace datalogics_interface::NamedColorSpace::device_cmyk()
```

*static*

**Returns:** [`NamedColorSpace`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/NamedColorSpace.md)

A new NamedColorSpace for DeviceCMYK (4 components).

Creates a NamedColorSpace representing the DeviceCMYK color space.

### device_gray

```cpp
static NamedColorSpace datalogics_interface::NamedColorSpace::device_gray()
```

*static*

**Returns:** [`NamedColorSpace`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/NamedColorSpace.md)

A new NamedColorSpace for DeviceGray (1 component).

Creates a NamedColorSpace representing the DeviceGray color space.

### device_rgb

```cpp
static NamedColorSpace datalogics_interface::NamedColorSpace::device_rgb()
```

*static*

**Returns:** [`NamedColorSpace`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/NamedColorSpace.md)

A new NamedColorSpace for DeviceRGB (3 components).

Creates a NamedColorSpace representing the DeviceRGB 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.
