pdftron::PDF::ColorSpace Class Reference

This abstract class is used to serve as a color space tag to identify the specific color space of a Color object. More...

#include <ColorSpace.h>

List of all members.

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)
 Create a ColorSpace from the given SDF/Cos object listed under ColorSpaces entry in page Resource dictionary.
 ColorSpace (const ColorSpace &c)
ColorSpaceoperator= (const ColorSpace &c)
 ~ColorSpace ()
 Destructor.
Type GetType () const
SDF::Obj GetSDFObj ()
int GetComponentNum ()
void InitColor (ColorPt &out_colorants)
 Set color to the initial value used for this color space.
void InitComponentRanges (std::vector< double > &out_decode_low, std::vector< double > &out_decode_range)
 Initialize default ranges for each color component in the color space.
void Convert2Gray (const ColorPt &in_color, ColorPt &out_color)
 A convenience function used to convert color points from the current color space to DeviceGray color space.
void Convert2RGB (const ColorPt &in_color, ColorPt &out_color)
 A convenience function used to convert color points from the current color space to DeviceRGB color space.
void Convert2CMYK (const ColorPt &in_color, ColorPt &out_color)
 A convenience function used to convert color points from the current color space to DeviceCMYK color space.
ColorSpace GetAlternateColorSpace ()
ColorSpace GetBaseColorSpace ()
int GetHighVal ()
const UCharGetLookupTable ()
void GetBaseColor (UChar color_idx, ColorPt &out_color)
 Get the base color given a component value (index) in Indexed color space.
bool IsNone ()
bool IsAll ()
Function GetTintFunction ()

Static Public Member Functions

static ColorSpace CreateDeviceGray ()
 Create a new DeviceGray ColorSpace object.
static ColorSpace CreateDeviceRGB ()
 Create a new DeviceRGB ColorSpace object.
static ColorSpace CreateDeviceCMYK ()
 Create a new DeviceCMYK ColorSpace object.
static ColorSpace CreatePattern ()
 Create a new Pattern ColorSpace object.
static ColorSpace CreateICC (SDF::SDFDoc &doc, const UString &filepath)
 Create a PDF 'ICCBased' color space given an ICC profile.
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.

Member Enumeration Documentation

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 


Constructor & Destructor Documentation

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.

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

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

Destructor.


Member Function Documentation

static ColorSpace pdftron::PDF::ColorSpace::CreateDeviceGray (  )  [static]

Create a new DeviceGray ColorSpace object.

static ColorSpace pdftron::PDF::ColorSpace::CreateDeviceRGB (  )  [static]

Create a new DeviceRGB ColorSpace object.

static ColorSpace pdftron::PDF::ColorSpace::CreateDeviceCMYK (  )  [static]

Create a new DeviceCMYK ColorSpace object.

static ColorSpace pdftron::PDF::ColorSpace::CreatePattern (  )  [static]

Create a new Pattern ColorSpace object.

static ColorSpace pdftron::PDF::ColorSpace::CreateICC ( SDF::SDFDoc doc,
const UString filepath 
) [static]

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

static ColorSpace pdftron::PDF::ColorSpace::CreateICC ( SDF::SDFDoc doc,
Filters::Filter  stm 
) [static]

static ColorSpace pdftron::PDF::ColorSpace::CreateICC ( SDF::SDFDoc doc,
const UChar buf,
size_t  buf_sz 
) [static]

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

static 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 
cs Cos/SDF color space object.

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

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

Returns:
The type of this color space

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

Returns:
the underlying SDF/Cos object

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

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

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

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:
an vector of numbers representing the lower bound for each color component.
an vector of numbers representing the 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.

void pdftron::PDF::ColorSpace::Convert2Gray ( const ColorPt in_color,
ColorPt out_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.

void pdftron::PDF::ColorSpace::Convert2RGB ( const ColorPt in_color,
ColorPt out_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.

void pdftron::PDF::ColorSpace::Convert2CMYK ( const ColorPt in_color,
ColorPt out_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.

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.

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.

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.

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.

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

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.

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.

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.

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.


© 2002-2010 PDFTron Systems Inc.