# DeviceNColorSpace Class

> Represents a color space with an arbitrary number of color components.

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

```cpp
class DeviceNColorSpace : ColorSpace
```

**Namespace:** `datalogics_interface`

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

## Description

Represents a color space with an arbitrary number of color components.

DeviceN color spaces were designed to represent color spaces containing multiple color components that correspond to the colorants of some target device. They provide greater flexibility than is possible with standard device color spaces such as DeviceCMYK or with individual Separation color spaces. For example, it is possible to create a DeviceN color space consisting of only the cyan, magenta, and yellow color components, with the black component excluded.

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

## Constructors

### DeviceNColorSpace

```cpp
datalogics_interface::DeviceNColorSpace::DeviceNColorSpace(const std::vector< std::string > &names, const ColorSpace &alternate, const Function &tint_transform)
```

*constructor*

**Parameters**

- `names` (`const std::vector< std::string > &`): the names of the colorants that the DeviceN space is intended to represent, among which may be All, or None
- `alternate` ([`const ColorSpace &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/ColorSpace.md)): the alternate color space, which can be any device or CIE-based color space but not another special color space (Pattern, Indexed, Separation, or DeviceN).
- `tint_transform` ([`const Function &`](https://docs.datalogics.com/apdfl21/ModernCPP/21.4.0/class/Function.md)): function, called with the tint value and returning the corresponding color component values. That is, the number of components and the interpretation of their values depend on the alternate color space.

Create a DeviceN color space.

## Methods

### get_alternate

```cpp
std::unique_ptr< ColorSpace > datalogics_interface::DeviceNColorSpace::get_alternate() const
```

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

the alternate color space, which can be any device or CIE-based color space but not another special color space (Pattern, Indexed, Separation, or DeviceN).

### get_attributes

```cpp
std::unique_ptr< PDFDict > datalogics_interface::DeviceNColorSpace::get_attributes() const
```

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

The dictionary of extended attributes associated with the color space.

### get_function

```cpp
std::unique_ptr< Function > datalogics_interface::DeviceNColorSpace::get_function() const
```

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

A function, called with the tint value and returning the corresponding color component values. That is, the number of components and the interpretation of their values depend on the alternate 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_names

```cpp
std::vector< std::string > datalogics_interface::DeviceNColorSpace::get_names() const
```

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

the names of the colorant that the DeviceN space is intended to represent, some of which may be All or None

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