PDF SDK Documentation

Comprehensive Guide for Developers: Features, Integration, and API Reference

Loading...
Searching...
No Matches
PDF::ColorSpace Class Reference

Represents a color space in a PDF document. More...

#include <pdfsdk/cxx/color_space.h>

Inheritance diagram for PDF::ColorSpace:

Public Member Functions

Object GetPdfObject () const
 Get the PDF object associated with this color space.
 
PDEColorSpaceFamily GetFamily () const
 Gets the color space family.
 
size_t GetNumComponents () const
 Gets the number of components that make up a color space.
 
PDENumRange GetComponentRange (size_t index) const
 Gets the range of values for a specific component in the color space.
 
bool HasVisibleOutput () const
 Checks if the color space produces visible output.
 
 ColorSpace (PDEColorSpace handle, bool adopt=false) noexcept
 
 ColorSpace (const ColorSpace &rhs) noexcept
 
ColorSpaceoperator= (const ColorSpace &rhs) noexcept
 
 ColorSpace (ColorSpace &&rhs) noexcept
 
ColorSpaceoperator= (ColorSpace &&rhs) noexcept
 

Static Public Member Functions

static ColorSpace GetDeviceGray ()
 Gets the DeviceGray color space.
 
static ColorSpace GetDeviceRGB ()
 Gets the DeviceRGB color space.
 
static ColorSpace GetDeviceCMYK ()
 Gets the DeviceCMYK color space.
 
static ColorSpace GetPattern ()
 Gets the Pattern color space.
 
static ColorSpace CreateFromPdfObject (const Object &object)
 Creates a color space from the specified PDF object.
 

Detailed Description

Represents a color space in a PDF document.

Color spaces or color systems describe both how colors are represented by the rendering device and how they are perceived by the human eye. They fall within three families sharing the same general characteristics: Device, CIE-based and Special color spaces. The Device color space family directly specifies colors or shades of gray that the output device shall produce. They provide a variety of color specification methods, including Grayscale, RGB (red-green-blue), and CMYK (cyan-magenta-yellow-black), corresponding to the color space families DeviceGray, DeviceRGB, and DeviceCMYK. The CIE-based color spaces are based on an international standard for color specification and specify colors in a way that is independent of the characteristics of any particular output device. This family includes the CalGray, CalRGB, Lab, and ICCBased spaces. The Special color spaces add features or properties to an underlying color space. They include facilities for patterns, color mapping, separations, high-fidelity and multitone color. The corresponding color space families are Pattern, Indexed, Separation, and DeviceN.

For more information refer to section 8.6 Color spaces, from the ISO 32000-2:2020 (PDF 2.0) Standard.

Member Function Documentation

◆ CreateFromPdfObject()

static ColorSpace PDF::ColorSpace::CreateFromPdfObject ( const Object & object)
static

Creates a color space from the specified PDF object.

There are several types of PDF objects that can be used to create color spaces. These can include name, array, dictionary or stream objects (if they are part of dictionaries).

Parameters
[in]objectA reference to the PDF object.
Returns
The color space.

◆ GetComponentRange()

PDENumRange PDF::ColorSpace::GetComponentRange ( size_t index) const

Gets the range of values for a specific component in the color space.

The component range refers to the numerical limits that define how much of each color channel can be present. It determines possible intensity or contribution of a particular component within the overall color representation. This ensures proper scaling of colors when converting between spaces. It can help normalize colors for different devices and can prevent out-of-gamut colors, ensuring they are properly handled in rendering.

Parameters
[in]indexThe index of the component.
Returns
The range of values.

◆ GetDeviceCMYK()

static ColorSpace PDF::ColorSpace::GetDeviceCMYK ( )
static

Gets the DeviceCMYK color space.

The DeviceCMYK color space specifies colors according to the subtractive cyan-magenta-yellow-black model typical of printers and other paper-based output devices. It specifies the intensities of these four colors using values between 0 and 1, where 0 denotes the complete absence and 1 denotes the maximum intensity of a color. See 8.6.4.4 DeviceCMYK color space.

Returns
The DeviceCMYK color space.

◆ GetDeviceGray()

static ColorSpace PDF::ColorSpace::GetDeviceGray ( )
static

Gets the DeviceGray color space.

The DeviceGray color space controls the intensity of achromatic light on a scale between 0 and 1. Black represented by 0, white represented by 1 and intermediate values representing different gray levels. See 8.6.4.2 DeviceGray color space.

Returns
The DeviceGray color space.

◆ GetDeviceRGB()

static ColorSpace PDF::ColorSpace::GetDeviceRGB ( )
static

Gets the DeviceRGB color space.

The DeviceRGB color space specifies colors according to the additive red-green-blue color model. It specifies the intensities of the three primary colors using values between 0 and 1, where 0 denotes the complete absence and 1 denotes the maximum intensity of a color. See 8.6.4.3 DeviceRGB color space.

Returns
The DeviceRGB color space.

◆ GetFamily()

PDEColorSpaceFamily PDF::ColorSpace::GetFamily ( ) const

Gets the color space family.

There are three groups of color space families - Device, CIE-based and Special families, each having three, four and four members respectively. For the Device family these are DeviceGray, DeviceRGB and DeviceCMYK. For the CIE-based family they are CalGrey, CalRGB, Lab and ICCBased. For the Special family they are Indexed, Pattern, Separation and DeviceN spaces. See 8.6.3 color space families

Returns
The color space.

◆ GetNumComponents()

size_t PDF::ColorSpace::GetNumComponents ( ) const

Gets the number of components that make up a color space.

Each color space is made up of different components. For the Device color space family, these are the numeric values that represent the color intensities for the individual pixels. Gray, Red-Green-Blue and Cyan-Magenta-Yellow-Black for DeviceGray, DeviceRGB, DeviceCMYK respectively. For the CIE-based family, the CalGrey and CalRGB have Gray and Red-Green-Blue components respectively and each have calibration parameters - Gamma, WhitePoint, BlackPoint and Matrix (for CalRGB). The ICCBased can have components that vary - RGB, CMYK, or custom and also has an ICC profile (metadata) stream. The Lab space has 3 components Lightness, a (green–red), b (blue–yellow). The Indexed Special color space is made up of a Base color space and an Indexed lookup table, the Separation Special color space - Single colorant name and a Tint transform function. The DeviceN Special color space is made up of Multiple named colorants and a Tint transform function.

Returns
The number of components.

◆ GetPattern()

static ColorSpace PDF::ColorSpace::GetPattern ( )
static

Gets the Pattern color space.

The Pattern color space specifies that an area is to be painted with a pattern rather than a single color. The pattern shall be either a tiling pattern (Type 1) or a shading pattern (Type 2). See 8.6.6.2 Pattern color spaces and 8.7 Patterns.

Returns
The Pattern color space.

◆ GetPdfObject()

Object PDF::ColorSpace::GetPdfObject ( ) const

Get the PDF object associated with this color space.

There are several types of PDF objects that can be associated with a color space. These can include name, array, dictionary or stream objects (if they are part of dictionaries).

Returns
The PDF object.

◆ HasVisibleOutput()

bool PDF::ColorSpace::HasVisibleOutput ( ) const

Checks if the color space produces visible output.

Returns
true if the color space produces visible output, false otherwise.

The documentation for this class was generated from the following file: