PDF SDK Documentation

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

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

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

#include <pdfsdk/cxx/color.h>

Inheritance diagram for PDF::Color:

Public Member Functions

ColorSpace GetColorSpace () const
 Gets the color space of the color.
 
size_t GetNumComponents () const
 Gets the number of components in a color.
 
float GetComponent (size_t index) const
 Gets the color component at the specified index.
 
Pattern GetPattern () const
 Gets the type of pattern associated with a color. Either tilling or shading.
 
PDColorValue ToRGB (PDERenderingIntent intent) const
 Converts a color to its RGB color value, by providing the color's rendering intent.
 
PDColorValue ToARGB (float opacity, PDERenderingIntent intent) const
 Converts a color to its ARGB color value, by providing the color's opacity and rendering intent.
 
 Color (PDEColor handle, bool adopt=false) noexcept
 
 Color (const Color &rhs) noexcept
 
Coloroperator= (const Color &rhs) noexcept
 
 Color (Color &&rhs) noexcept
 
Coloroperator= (Color &&rhs) noexcept
 

Static Public Member Functions

static Color Create (const ColorSpace &colorSpace, const std::vector< float > &components, const Pattern &pattern)
 Creates a color by specifying a color space and the color components.
 
static Color CreateGray (float gray)
 Creates a grayscale color with the specified gray value.
 
static Color CreateRGB (float red, float green, float blue)
 Creates an RGB color by specifying the individual red, green, and blue values.
 
static Color CreateFromValue (PDColorValue value)
 Creates a color from the RGB color value.
 

Detailed Description

Represents a color in a PDF document.

Color values are made up of color components, which are usually represented by numbers. A grey level will be represented by a single number ranging from 0.0 (black) to 1.0 (white). Full color values can be specified in a number of ways, with the most common method using three numeric values one for each of the main colors - red, blue, green. Color values are interpreted according to the color space they belong to. Color spaces are parameters of the internal data structure called the graphics state. The rendering intent specifies how colors should be mapped from source to output device. First the color space is set, then the color values are specified and finally the rendering intent modifies how the colors are interpreted by the output device.

For more information refer to ISO 32000-2:2020 - 8.6.2 Color values

Member Function Documentation

◆ Create()

static Color PDF::Color::Create ( const ColorSpace & colorSpace,
const std::vector< float > & components,
const Pattern & pattern )
static

Creates a color by specifying a color space and the color components.

If the color space happens to be the one of the special color spaces called 'Pattern', then the optional pattern parameter should be used to specify the pattern type - tilling or shading.

Parameters
colorSpaceThe color space of the color.
See also
ColorSpace
Parameters
componentsThe components of the color. A color value consists of one or more components. A grey level is specified by a single number ranging from 0.0 (black) to 1.0 (white). Full color values may be specified in one of several ways. One common way is by specifying red-green-blue components in that order.
patternIf colorSpace is Pattern, the pattern should be specifed as either tilling or shading.
Returns
The created color.

◆ CreateFromValue()

static Color PDF::Color::CreateFromValue ( PDColorValue value)
static

Creates a color from the RGB color value.

Parameters
valueThe RGB bit-packed color value in 0xRRGGBB hex format.
Returns
The created color.

◆ CreateGray()

static Color PDF::Color::CreateGray ( float gray)
static

Creates a grayscale color with the specified gray value.

Parameters
grayThe gray value of the color ranging from 0.0 (black) to 1.0 (white).
Returns
The created grayscale color.

◆ CreateRGB()

static Color PDF::Color::CreateRGB ( float red,
float green,
float blue )
static

Creates an RGB color by specifying the individual red, green, and blue values.

Parameters
redThe red value of the color. With a range between 0.0 (absence of) to 1.0 (full color).
greenThe green value of the color. With a range between 0.0 (absence of) to 1.0 (full color).
blueThe blue value of the color. With a range between 0.0 (absence of) to 1.0 (full color).
Returns
The created RGB color.

◆ GetColorSpace()

ColorSpace PDF::Color::GetColorSpace ( ) const

Gets the color space of the color.

See also
ColorSpace
Returns
The color space associated with a color.

◆ GetComponent()

float PDF::Color::GetComponent ( size_t index) const

Gets the color component at the specified index.

Parameters
indexThe index of the color component.
Returns
The component value.

◆ GetNumComponents()

size_t PDF::Color::GetNumComponents ( ) const

Gets the number of components in a color.

Returns
The number of components of a color.

◆ GetPattern()

Pattern PDF::Color::GetPattern ( ) const

Gets the type of pattern associated with a color. Either tilling or shading.

Only applicable if the color space family this color belongs to is of the special 'Pattern' type.

Returns
The pattern type associated with this color. Either tilling or shading.
See also
Pattern

◆ ToARGB()

PDColorValue PDF::Color::ToARGB ( float opacity,
PDERenderingIntent intent ) const

Converts a color to its ARGB color value, by providing the color's opacity and rendering intent.

Parameters
opacityThe opacity value ranging from 0.0 (fully transparent) to 1.0 (opaque)
intentThe rendering intent.
See also
PDERenderingIntent
Returns
The ARGB bit-packed color value in 0xAARRGGBB hex format.

◆ ToRGB()

PDColorValue PDF::Color::ToRGB ( PDERenderingIntent intent) const

Converts a color to its RGB color value, by providing the color's rendering intent.

Parameters
intentThe rendering intent.
See also
PDERenderingIntent
Returns
The RGB bit-packed color value in 0xRRGGBB hex format.

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