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

`#include <ColorSpace.h>`

## Public Types
enum | Type { e_device_gray , e_device_rgb , e_device_cmyk , e_cal_gray , e_cal_rgb , e_lab , e_icc , e_indexed , e_pattern , e_separation , e_device_n , e_null }

## Public Member Functions
| ColorSpace (SDF::Obj color_space=0)
| ColorSpace (const ColorSpace &c)
ColorSpace & | operator= (const ColorSpace &c)
| ~ColorSpace ()
Type | GetType () const
SDF::Obj | GetSDFObj ()
int | GetComponentNum ()
void | InitColor (ColorPt &out_colorants)
void | InitComponentRanges (std::vector< double > &out_decode_low, std::vector< double > &out_decode_range)
ColorPt | Convert2Gray (const ColorPt &in_color)
void | Convert2Gray (const ColorPt &in_color, ColorPt &out_color)
ColorPt | Convert2RGB (const ColorPt &in_color)
void | Convert2RGB (const ColorPt &in_color, ColorPt &out_color)
ColorPt | Convert2CMYK (const ColorPt &in_color)
void | Convert2CMYK (const ColorPt &in_color, ColorPt &out_color)
ColorSpace | GetAlternateColorSpace ()
ColorSpace | GetBaseColorSpace ()
int | GetHighVal ()
const UChar * | GetLookupTable ()
ColorPt | GetBaseColor (UChar color_idx)
void | GetBaseColor (UChar color_idx, ColorPt &out_color)
bool | IsNone ()
bool | IsAll ()
Function | GetTintFunction ()
void | Destroy ()

## Static Public Member Functions
static ColorSpace | CreateDeviceGray ()
static ColorSpace | CreateDeviceRGB ()
static ColorSpace | CreateDeviceCMYK ()
static ColorSpace | CreatePattern ()
static ColorSpace | CreateICC (SDF::SDFDoc &doc, const UString &filepath)
static ColorSpace | CreateICC (SDF::SDFDoc &doc, Filters::Filter stm)
static ColorSpace | CreateICC (SDF::SDFDoc &doc, const UChar *buf, size_t buf_sz)
static int | GetComponentNum (Type cs_type, SDF::Obj cs)
static Type | GetType (SDF::Obj cs)

## Detailed Description

This abstract class is used to serve as a color space tag to identify the specific color space of a Color object. It contains methods that transform colors in a specific color space to/from several color space such as DeviceRGB and DeviceCMYK.

For purposes of the methods in this class, colors are represented as arrays of color components represented as doubles in a normalized range defined by each ColorSpace. For many ColorSpaces (e.g. DeviceRGB), this range is 0.0 to 1.0. However, some ColorSpaces have components whose values have a different range. Methods are provided to inquire per component minimum and maximum normalized values.

Note
  Note that in Pattern color space (i.e. for ColorSpace::e_pattern) 'color values' are PDF::PatternColor objects instead of the numeric component values (i.e. ColorPt) used with other spaces.

Definition at line 138 of file ColorSpace.h.

## Member Enumeration Documentation

## ◆ Type

enum pdftron::PDF::ColorSpace::Type

Enumerator
e_device_gray |
e_device_rgb |
e_device_cmyk |
e_cal_gray |
e_cal_rgb |
e_lab |
e_icc |
e_indexed |
e_pattern |
e_separation |
e_device_n |
e_null |

Definition at line 186 of file ColorSpace.h.

## Constructor & Destructor Documentation

## ◆ ColorSpace() [1/2]

pdftron::PDF::ColorSpace::ColorSpace | ( | SDF::Obj | color_space = 0 | ) |

Create a ColorSpace from the given SDF/Cos object listed under ColorSpaces entry in page Resource dictionary. If color_space dictionary is null, a non valid ColorSpace object is created.

Parameters

  color_space | The Cos/SDF object to initialze the ColorSpace object with.

## ◆ ColorSpace() [2/2]

pdftron::PDF::ColorSpace::ColorSpace | ( | const ColorSpace & | c | ) |

## ◆ ~ColorSpace()

pdftron::PDF::ColorSpace::~ColorSpace | ( |  | ) |

Destructor

## Member Function Documentation

## ◆ Convert2CMYK() [1/2]

ColorPt pdftron::PDF::ColorSpace::Convert2CMYK | ( | const ColorPt & | in_color | ) |

A convenience function used to convert color points from the current color space to DeviceCMYK color space.

Parameters

  in_color | input color point in the current color space
  out_color | output color point in the DeviceCMYK color space

Note
  the number to input colorants must match the number of colorants expected by the current color space.

## ◆ Convert2CMYK() [2/2]

void pdftron::PDF::ColorSpace::Convert2CMYK | ( | const ColorPt & | in_color,
|  | ColorPt & | out_color )

## ◆ Convert2Gray() [1/2]

ColorPt pdftron::PDF::ColorSpace::Convert2Gray | ( | const ColorPt & | in_color | ) |

A convenience function used to convert color points from the current color space to DeviceGray color space.

Parameters

  in_color | input color point in the current color space
  out_color | output color point in the DeviceGray color space

Note
  the number to input colorants must match the number of colorants expected by the current color space.

## ◆ Convert2Gray() [2/2]

void pdftron::PDF::ColorSpace::Convert2Gray | ( | const ColorPt & | in_color,
|  | ColorPt & | out_color )

## ◆ Convert2RGB() [1/2]

ColorPt pdftron::PDF::ColorSpace::Convert2RGB | ( | const ColorPt & | in_color | ) |

A convenience function used to convert color points from the current color space to DeviceRGB color space.

Parameters

  in_color | input color point in the current color space
  out_color | output color point in the DeviceRGB color space

Note
  the number to input colorants must match the number of colorants expected by the current color space.

## ◆ Convert2RGB() [2/2]

void pdftron::PDF::ColorSpace::Convert2RGB | ( | const ColorPt & | in_color,
|  | ColorPt & | out_color )

## ◆ CreateDeviceCMYK()

ColorSpace pdftron::PDF::ColorSpace::CreateDeviceCMYK | ( |  | ) |
| static

Create a new DeviceCMYK ColorSpace object

## ◆ CreateDeviceGray()

ColorSpace pdftron::PDF::ColorSpace::CreateDeviceGray | ( |  | ) |
| static

Create a new DeviceGray ColorSpace object

## ◆ CreateDeviceRGB()

ColorSpace pdftron::PDF::ColorSpace::CreateDeviceRGB | ( |  | ) |
| static

Create a new DeviceRGB ColorSpace object

## ◆ CreateICC() [1/3]

ColorSpace pdftron::PDF::ColorSpace::CreateICC | ( | SDF::SDFDoc & | doc,
|  | const UChar * | buf,
|  | size_t | buf_sz )
| static

## ◆ CreateICC() [2/3]

ColorSpace pdftron::PDF::ColorSpace::CreateICC | ( | SDF::SDFDoc & | doc,
|  | const UString & | filepath )
| static

Create a PDF 'ICCBased' color space given an ICC profile

## ◆ CreateICC() [3/3]

ColorSpace pdftron::PDF::ColorSpace::CreateICC | ( | SDF::SDFDoc & | doc,
|  | Filters::Filter | stm )
| static

## ◆ CreatePattern()

ColorSpace pdftron::PDF::ColorSpace::CreatePattern | ( |  | ) |
| static

Create a new Pattern ColorSpace object

## ◆ Destroy()

void pdftron::PDF::ColorSpace::Destroy | ( |  | ) |

Frees the native memory of the object.

## ◆ GetAlternateColorSpace()

ColorSpace pdftron::PDF::ColorSpace::GetAlternateColorSpace | ( |  | ) |

Returns
  the alternate color space if it is available or NULL otherwise. Color spaces that include alternate color space are e_separation, e_device_n, and e_icc.

## ◆ GetBaseColor() [1/2]

ColorPt pdftron::PDF::ColorSpace::GetBaseColor | ( | UChar | color_idx | ) |

Get the base color given a component value (index) in Indexed color space.

Parameters

  color_idx | color value represented in the index color space
  out_color | the color represented in the base (associated) color space

Note
  for color spaces other than Indexed this method throws an exception.

## ◆ GetBaseColor() [2/2]

void pdftron::PDF::ColorSpace::GetBaseColor | ( | UChar | color_idx,
|  | ColorPt & | out_color )

## ◆ GetBaseColorSpace()

ColorSpace pdftron::PDF::ColorSpace::GetBaseColorSpace | ( |  | ) |

Returns
  the base color space if this is an e_indexed or e_pattern with associated base color space; NULL otherwise.

## ◆ GetComponentNum() [1/2]

int pdftron::PDF::ColorSpace::GetComponentNum | ( |  | ) |

Returns
  The number of colorants (tint components) used to represent color point in this color space

## ◆ GetComponentNum() [2/2]

int pdftron::PDF::ColorSpace::GetComponentNum | ( | Type | cs_type,
|  | SDF::Obj | cs )
| static

Returns
  The number of components (tint components) used to represent color point for this color space

Parameters

  cs_type | The color space type.
  cs | Cos/SDF color space object.

## ◆ GetHighVal()

int pdftron::PDF::ColorSpace::GetHighVal | ( |  | ) |

Returns
  the highest index for the color lookup table for Indexed color space. Since the color table is indexed from zero to highval, the actual number of entries is highval + 1. For color spaces other than indexed the method returns 0.

Note
  for color spaces other than Indexed this method throws an exception.

## ◆ GetLookupTable()

const UChar * pdftron::PDF::ColorSpace::GetLookupTable | ( |  | ) |

Returns
  the color lookup table for Indexed color space. for color spaces other than indexed the method returns NULL.

Note
  for color spaces other than Indexed this method throws an exception.

## ◆ GetSDFObj()

SDF::Obj pdftron::PDF::ColorSpace::GetSDFObj | ( |  | ) |

Returns
  the underlying SDF/Cos object

## ◆ GetTintFunction()

Function pdftron::PDF::ColorSpace::GetTintFunction | ( |  | ) |

Returns
  the function that transforms tint values into color component values in the alternate color space.

Note
  for color spaces other than Separation this method throws an exception.

## ◆ GetType() [1/2]

Type pdftron::PDF::ColorSpace::GetType | ( |  | ) | const

Returns
  The type of this color space

## ◆ GetType() [2/2]

Type pdftron::PDF::ColorSpace::GetType | ( | SDF::Obj | cs | ) |
| static

Returns
  The Type of a given SDF/Cos color space, or e_null for if SDF object is not a valid color space

Parameters

  cs | Cos/SDF color space object.

## ◆ InitColor()

void pdftron::PDF::ColorSpace::InitColor | ( | ColorPt & | out_colorants | ) |

Set color to the initial value used for this color space. The initial value depends on the color space (see 4.5.7 in PDF Ref. Manual).

Parameters

  out_colorants | ColorPt object to initialize.

## ◆ InitComponentRanges()

void pdftron::PDF::ColorSpace::InitComponentRanges | ( | std::vector< double > & | out_decode_low,
|  | std::vector< double > & | out_decode_range )

Initialize default ranges for each color component in the color space. For example, default ranges for DeviceRGB are [0 1 0 1 0 1] but for Lab the default values might be [0 100 -100 100 -100 100].

Parameters

  out_decode_low | a vector of numbers representing the lower bound for each color component.
  out_decode_range | a vector of numbers representing the difference between high and low bound for each color component.

Note
  the size of resulting vectors will match the number of color components in this color space.

## ◆ IsAll()

bool pdftron::PDF::ColorSpace::IsAll | ( |  | ) |

Returns
  True if Separation color space contains the colorant All.

Note
  for color spaces other than Separation this method throws an exception.

## ◆ IsNone()

bool pdftron::PDF::ColorSpace::IsNone | ( |  | ) |

Returns
  True if Separation or DeviceN color space contains None colorants. For DeviceN the function returns true only if component colorant names are all None.

Note
  for color spaces other than Separation or DeviceN this method throws an exception.

## ◆ operator=()

ColorSpace & pdftron::PDF::ColorSpace::operator= | ( | const ColorSpace & | c | ) |

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

- PDF/ColorSpace.h