PoDoFo  0.9.4
Public Member Functions | Static Public Member Functions | List of all members
PoDoFo::PdfColor Class Reference

#include <PdfColor.h>

Inherited by PoDoFo::PdfColorCieLab, PoDoFo::PdfColorCMYK, PoDoFo::PdfColorGray, PoDoFo::PdfColorRGB, PoDoFo::PdfColorSeparation, PoDoFo::PdfColorSeparationAll, and PoDoFo::PdfColorSeparationNone.

Public Member Functions

 PdfColor ()
 
 PdfColor (double dGray)
 
 PdfColor (double dRed, double dGreen, double dBlue)
 
 PdfColor (double dCyan, double dMagenta, double dYellow, double dBlack)
 
 PdfColor (const PdfColor &rhs)
 
virtual ~PdfColor ()
 
const PdfColoroperator= (const PdfColor &rhs)
 
bool operator== (const PdfColor &rhs) const
 
bool operator!= (const PdfColor &rhs) const
 
bool IsGrayScale () const
 
bool IsRGB () const
 
bool IsCMYK () const
 
bool IsSeparation () const
 
bool IsCieLab () const
 
EPdfColorSpace GetColorSpace () const
 
EPdfColorSpace GetAlternateColorSpace () const
 
double GetGrayScale () const
 
double GetRed () const
 
double GetGreen () const
 
double GetBlue () const
 
double GetCyan () const
 
double GetMagenta () const
 
double GetYellow () const
 
double GetBlack () const
 
const std::string GetName () const
 
double GetDensity () const
 
double GetCieL () const
 
double GetCieA () const
 
double GetCieB () const
 
PdfColor ConvertToGrayScale () const
 
PdfColor ConvertToRGB () const
 
PdfColor ConvertToCMYK () const
 
PdfArray ToArray () const
 
PdfObjectBuildColorSpace (PdfVecObjects *pOwner) const
 

Static Public Member Functions

static PdfColor FromString (const char *pszName)
 
static PdfColor FromArray (const PdfArray &rArray)
 
static EPdfColorSpace GetColorSpaceForName (const PdfName &rName)
 
static PdfName GetNameForColorSpace (EPdfColorSpace eColorSpace)
 

Detailed Description

A color object can represent either a grayscale value, a RGB color, a CMYK color, a separation color or a CieLab color.

All drawing functions in PoDoFo accept a PdfColor object to specify a drawing color in one of these colorspaces.

Derived classes PdfColorGray, PdfColorRGB, PdfColorCMYK, PdfColorSeparation and PdfColorCieLab are available for easy construction

Constructor & Destructor Documentation

PoDoFo::PdfColor::PdfColor ( )

Create a PdfColor object that is RGB black.

PoDoFo::PdfColor::PdfColor ( double  dGray)
explicit

Create a new PdfColor object with a grayscale value.

Parameters
dGraya grayscalue value between 0.0 and 1.0
PoDoFo::PdfColor::PdfColor ( double  dRed,
double  dGreen,
double  dBlue 
)

Create a new PdfColor object with a RGB color

Parameters
dRedthe value of the red component, must be between 0.0 and 1.0
dGreenthe value of the green component, must be between 0.0 and 1.0
dBluethe value of the blue component, must be between 0.0 and 1.0
PoDoFo::PdfColor::PdfColor ( double  dCyan,
double  dMagenta,
double  dYellow,
double  dBlack 
)

Create a new PdfColor object with a CMYK color

Parameters
dCyanthe value of the cyan component, must be between 0.0 and 1.0
dMagentathe value of the magenta component, must be between 0.0 and 1.0
dYellowthe value of the yellow component, must be between 0.0 and 1.0
dBlackthe value of the black component, must be between 0.0 and 1.0
PoDoFo::PdfColor::PdfColor ( const PdfColor rhs)

Copy constructor

Parameters
rhscopy rhs into this object
PoDoFo::PdfColor::~PdfColor ( )
virtual

Destructor

Member Function Documentation

PdfObject * PoDoFo::PdfColor::BuildColorSpace ( PdfVecObjects pOwner) const

Creates a colorspace object from a color to insert into resources.

Parameters
pOwnera pointer to the owner of the generated object
Returns
a PdfObject pointer, which can be insert into resources, NULL if not needed
PdfColor PoDoFo::PdfColor::ConvertToCMYK ( ) const

Converts the color object into a CMYK color object.

This is only a convinience function. It might be useful for on screen display but is in NO WAY suitable to professional printing!

Returns
a CMYK color object
See also
IsCMYK()
PdfColor PoDoFo::PdfColor::ConvertToGrayScale ( ) const

Converts the color object into a grayscale color object.

This is only a convinience function. It might be useful for on screen display but is in NO WAY suitable to professional printing!

Returns
a grayscale color object
See also
IsGrayScale()
PdfColor PoDoFo::PdfColor::ConvertToRGB ( ) const

Converts the color object into a RGB color object.

This is only a convinience function. It might be useful for on screen display but is in NO WAY suitable to professional printing!

Returns
a RGB color object
See also
IsRGB()
PdfColor PoDoFo::PdfColor::FromArray ( const PdfArray rArray)
static

Creates a color object from a PdfArray which represents a color.

Raises an exception if this is no PdfColor!

Parameters
rArrayan array that must be a color PdfArray
Returns
a PdfColor object
PdfColor PoDoFo::PdfColor::FromString ( const char *  pszName)
static

Creates a color object from a string.

Parameters
pszNamea string describing a color.

Supported values are:

  • single gray values as string (e.g. '0.5')
  • a named color (e.g. 'auquamarine' or 'magenta')
  • hex values (e.g. #FF002A (RGB) or #FF12AB3D (CMYK))
  • PdfArray's
Returns
a PdfColor object
EPdfColorSpace PoDoFo::PdfColor::GetAlternateColorSpace ( ) const
inline

Get the alternate colorspace of this PdfColor object

Returns
the colorspace of this PdfColor object (must be separation)
double PoDoFo::PdfColor::GetBlack ( ) const
inline

Get the black color value of this object.

Throws an exception if this is no CMYK or separation color object.

Returns
the black color value of this object (between 0.0 and 1.0)
See also
IsCMYK
double PoDoFo::PdfColor::GetBlue ( ) const
inline

Get the blue color value of this object.

Throws an exception if this is no RGB color object.

Returns
the blue color value of this object (between 0.0 and 1.0)
See also
IsRGB
double PoDoFo::PdfColor::GetCieA ( ) const
inline

Get the A color value of this object.

Throws an exception if this is no CIE-Lab color object.

Returns
the A color value of this object (between -128.0 and 127.0)
See also
IsCieLab
double PoDoFo::PdfColor::GetCieB ( ) const
inline

Get the B color value of this object.

Throws an exception if this is no CIE-Lab color object.

Returns
the B color value of this object (between -128.0 and 127.0)
See also
IsCieLab
double PoDoFo::PdfColor::GetCieL ( ) const
inline

Get the L color value of this object.

Throws an exception if this is no CIE-Lab color object.

Returns
the L color value of this object (between 0.0 and 100.0)
See also
IsCieLab
EPdfColorSpace PoDoFo::PdfColor::GetColorSpace ( ) const
inline

Get the colorspace of this PdfColor object

Returns
the colorspace of this PdfColor object
EPdfColorSpace PoDoFo::PdfColor::GetColorSpaceForName ( const PdfName rName)
static

Convert a name into a colorspace enum.

Parameters
rNamename representing a colorspace such as DeviceGray
Returns
colorspace enum or ePdfColorSpace_Unknown if name is unknown
See also
GetNameForColorSpace
double PoDoFo::PdfColor::GetCyan ( ) const
inline

Get the cyan color value of this object.

Throws an exception if this is no CMYK or separation color object.

Returns
the cyan color value of this object (between 0.0 and 1.0)
See also
IsCMYK
double PoDoFo::PdfColor::GetDensity ( ) const
inline

Get the density color value of this object.

Throws an exception if this is no separation color object.

Returns
the density value of this object (between 0.0 and 1.0)
See also
IsSeparation
double PoDoFo::PdfColor::GetGrayScale ( ) const
inline

Get the grayscale color value of this object.

Throws an exception if this is no grayscale color object.

Returns
the grayscale color value of this object (between 0.0 and 1.0)
See also
IsGrayScale
double PoDoFo::PdfColor::GetGreen ( ) const
inline

Get the green color value of this object.

Throws an exception if this is no RGB color object.

Returns
the green color value of this object (between 0.0 and 1.0)
See also
IsRGB
double PoDoFo::PdfColor::GetMagenta ( ) const
inline

Get the magenta color value of this object.

Throws an exception if this is no CMYK or separation color object.

Returns
the magenta color value of this object (between 0.0 and 1.0)
See also
IsCMYK
const std::string PoDoFo::PdfColor::GetName ( ) const
inline

Get the separation name of this object.

Throws an exception if this is no separation color object.

Returns
the name of this object
See also
IsSeparation
PdfName PoDoFo::PdfColor::GetNameForColorSpace ( EPdfColorSpace  eColorSpace)
static

Convert a colorspace enum value into a name such as DeviceRGB

Parameters
eColorSpacea colorspace
Returns
a name
See also
GetColorSpaceForName
double PoDoFo::PdfColor::GetRed ( ) const
inline

Get the red color value of this object.

Throws an exception if this is no RGB color object.

Returns
the red color value of this object (between 0.0 and 1.0)
See also
IsRGB
double PoDoFo::PdfColor::GetYellow ( ) const
inline

Get the yellow color value of this object.

Throws an exception if this is no CMYK or separation color object.

Returns
the yellow color value of this object (between 0.0 and 1.0)
See also
IsCMYK
bool PoDoFo::PdfColor::IsCieLab ( ) const
inline

Test if this is a CIE-Lab color.

Returns
true if this is a lab Color object
bool PoDoFo::PdfColor::IsCMYK ( ) const
inline

Test if this is a CMYK color.

Returns
true if this is a CMYK PdfColor object
bool PoDoFo::PdfColor::IsGrayScale ( ) const
inline

Test if this is a grayscale color.

Returns
true if this is a grayscale PdfColor object
bool PoDoFo::PdfColor::IsRGB ( ) const
inline

Test if this is a RGB color.

Returns
true if this is a RGB PdfColor object
bool PoDoFo::PdfColor::IsSeparation ( ) const
inline

Test if this is a separation color.

Returns
true if this is a separation PdfColor object
bool PoDoFo::PdfColor::operator!= ( const PdfColor rhs) const
inline

Test for inequality of colors.

Parameters
rhscolor to compare ro
Returns
true if object color is not equal to rhs
const PdfColor & PoDoFo::PdfColor::operator= ( const PdfColor rhs)

Assignment operator

Parameters
rhscopy rhs into this object
Returns
a reference to this color object
bool PoDoFo::PdfColor::operator== ( const PdfColor rhs) const
inline

Test for equality of colors.

Parameters
rhscolor to compare ro
Returns
true if object color is equal to rhs
PdfArray PoDoFo::PdfColor::ToArray ( ) const

Creates a PdfArray which represents a color from a color.

Returns
a PdfArray object