Loading...
Searching...
No Matches
Magick::Color Class Reference
Inheritance diagram for Magick::Color:

## Public Types

enum | PixelType { CMYKPixel , CMYKAPixel , RGBPixel , RGBAPixel }

## Public Member Functions

| Color (const Magick::Quantum red_, const Magick::Quantum green_, const Magick::Quantum blue_)
| Color (const Magick::Quantum red_, const Magick::Quantum green_, const Magick::Quantum blue_, const Magick::Quantum alpha_)
| Color (const Magick::Quantum cyan_, const Magick::Quantum magenta_, const Magick::Quantum yellow_, const Magick::Quantum black_, const Magick::Quantum alpha_)
| Color (const char *color_)
| Color (const Color &color_)
| Color (const PixelInfo &color_)
| Color (const std::string &color_)
Color & | operator= (const Color &color_)
const Color & | operator= (const char *color)
const Color & | operator= (const PixelInfo &color_)
const Color & | operator= (const std::string &color)
| operator PixelInfo () const
| operator std::string () const
bool | isFuzzyEquivalent (const Color &color_, const double fuzz_) const
void | isValid (const bool valid_)
bool | isValid (void) const
Magick::Color::PixelType | pixelType (void) const
void | quantumAlpha (const Quantum alpha_)
Quantum | quantumAlpha (void) const
void | quantumBlack (const Quantum black_)
Quantum | quantumBlack (void) const
void | quantumBlue (const Quantum blue_)
Quantum | quantumBlue (void) const
void | quantumGreen (const Quantum green_)
Quantum | quantumGreen (void) const
void | quantumRed (const Quantum red_)
Quantum | quantumRed (void) const

## Protected Member Functions

| Color (PixelInfo *rep_, PixelType pixelType_)
| Color (PixelType pixelType_)
void | pixel (PixelInfo *rep_, PixelType pixelType_)

## Static Protected Member Functions

static Quantum | scaleDoubleToQuantum (const double double_)
static double | scaleQuantumToDouble (const Quantum quantum_)

## Protected Attributes

PixelInfo * | _pixel

## Private Member Functions

void | initPixel ()
void | setAlpha (const Magick::Quantum alpha_)
void | setPixelType (const PixelInfo &color_)

## Private Attributes

bool | _isValid
bool | _pixelOwn
PixelType | _pixelType

## Detailed Description

Definition at line 36 of file Color.h.

## Member Enumeration Documentation

## PixelType

enum Magick::Color::PixelType

Definition at line 61 of file Color.h.

{
CMYKPixel,
CMYKAPixel,
RGBPixel,
RGBAPixel
};

## Constructor & Destructor Documentation

## Color() [1/9]

Magick::Color::Color | ( | void |  | ) |

Definition at line 78 of file Color.cpp.

: _pixel(new PixelInfo),
_isValid(false),
_pixelOwn(true),
_pixelType(RGBAPixel)
{
initPixel();
setAlpha(TransparentAlpha);
}

## Color() [2/9]

Magick::Color::Color | ( | const Magick::Quantum | red_,
|  | const Magick::Quantum | green_,
|  | const Magick::Quantum | blue_,
|  | const Magick::Quantum | alpha_ )

Definition at line 105 of file Color.cpp.

: _pixel(new PixelInfo),
_isValid(true),
_pixelOwn(true),
_pixelType(RGBPixel)
{
initPixel();
quantumAlpha(alpha_);
quantumBlack(0);
quantumBlue(blue_);
quantumGreen(green_);
quantumRed(red_);
if (alpha_ != OpaqueAlpha)
_pixelType=RGBAPixel;
}

## Color() [3/9]

Magick::Color::Color | ( | const Magick::Quantum | cyan_,
|  | const Magick::Quantum | magenta_,
|  | const Magick::Quantum | yellow_,
|  | const Magick::Quantum | black_,
|  | const Magick::Quantum | alpha_ )

Definition at line 123 of file Color.cpp.

: _pixel(new PixelInfo),
_isValid(true),
_pixelOwn(true),
_pixelType(CMYKPixel)
{
initPixel();
quantumAlpha(alpha_);
quantumBlack(black_);
quantumBlue(yellow_);
quantumGreen(magenta_);
quantumRed(cyan_);
if (alpha_ != OpaqueAlpha)
_pixelType=CMYKAPixel;
}

## Color() [4/9]

Magick::Color::Color | ( | const char * | color_ | ) |

Definition at line 142 of file Color.cpp.

: _pixel(new PixelInfo),
_isValid(true),
_pixelOwn(true),
_pixelType(RGBPixel)
{
initPixel();
// Use operator = implementation
*this=color_;
}

## Color() [5/9]

Magick::Color::Color | ( | const Color & | color_ | ) |

Definition at line 154 of file Color.cpp.

: _pixel(new PixelInfo),
_isValid(color_._isValid),
_pixelOwn(true),
_pixelType(color_._pixelType)
{
*_pixel=*color_._pixel;
}

## Color() [6/9]

Magick::Color::Color | ( | const PixelInfo & | color_ | ) |

Definition at line 163 of file Color.cpp.

: _pixel(new PixelInfo),
_isValid(true),
_pixelOwn(true)
{
*_pixel=color_;
setPixelType(color_);
}

## Color() [7/9]

Magick::Color::Color | ( | const std::string & | color_ | ) |

Definition at line 172 of file Color.cpp.

: _pixel(new PixelInfo),
_isValid(true),
_pixelOwn(true),
_pixelType(RGBPixel)
{
initPixel();
// Use operator = implementation
*this=color_;
}

## ~Color()

Magick::Color::~Color | ( | void |  | ) |

virtual

Definition at line 184 of file Color.cpp.

{
if (_pixelOwn)
delete _pixel;
_pixel=(PixelInfo *)NULL;
}

## Color() [8/9]

Magick::Color::Color | ( | PixelInfo * | rep_,
|  | PixelType | pixelType_ )

protected

Definition at line 386 of file Color.cpp.

: _pixel(rep_),
_isValid(true),
_pixelOwn(false),
_pixelType(pixelType_)
{
}

## Color() [9/9]

Magick::Color::Color | ( | PixelType | pixelType_ | ) |

protected

Definition at line 377 of file Color.cpp.

: _pixel(new PixelInfo),
_isValid(false),
_pixelOwn(true),
_pixelType(pixelType_)
{
initPixel();
}

## Member Function Documentation

## initPixel()

void Magick::Color::initPixel | ( |  | ) |

private

Definition at line 419 of file Color.cpp.

{
MagickCore::GetPixelInfo((MagickCore::Image *) NULL, _pixel);
if (_pixelType == CMYKPixel || _pixelType == CMYKAPixel)
_pixel->colorspace=CMYKColorspace;
}

## isFuzzyEquivalent()

bool Magick::Color::isFuzzyEquivalent | ( | const Color & | color_,
|  | const double | fuzz_ ) const

Definition at line 283 of file Color.cpp.

{
PixelInfo
p,
q;
p=*_pixel;
p.fuzz=fuzz_;
q=*color_._pixel;
q.fuzz=fuzz_;
return (IsFuzzyEquivalencePixelInfo(&p, &q) != MagickFalse);
}

## isValid() [1/2]

void Magick::Color::isValid | ( | const bool | valid_ | ) |

Definition at line 306 of file Color.cpp.

{
if (bool(valid_) == bool(isValid()))
return;
if (!_pixelOwn)
{
_pixel=new PixelInfo;
_pixelOwn=true;
}
_isValid=valid_;
initPixel();
}

## isValid() [2/2]

bool Magick::Color::isValid | ( | void |  | ) | const

Definition at line 296 of file Color.cpp.

{
return(_isValid);
}

## operator std::string()

Magick::Color::operator std::string | ( |  | ) | const

Definition at line 258 of file Color.cpp.

{
char
colorbuf[MagickPathExtent];
PixelInfo
pixel;
if (!isValid())
return std::string("none");
pixel.colorspace=(_pixelType == RGBPixel || _pixelType == RGBAPixel) ?
sRGBColorspace : CMYKColorspace;
pixel.depth=MAGICKCORE_QUANTUM_DEPTH;
pixel.alpha=_pixel->alpha;
pixel.alpha_trait=_pixel->alpha_trait;
pixel.black=_pixel->black;
pixel.blue=_pixel->blue;
pixel.green=_pixel->green;
pixel.red=_pixel->red;
GetColorTuple(&pixel,MagickTrue,colorbuf);
return(std::string(colorbuf));
}

## operator=() [1/3]

const Magick::Color & Magick::Color::operator= | ( | const char * | color | ) |

Definition at line 209 of file Color.cpp.

{
*this=std::string(color_);
return(*this);
}

## operator=() [2/3]

Magick::Color & Magick::Color::operator= | ( | const Color & | color_ | ) |

Definition at line 192 of file Color.cpp.

{
// If not being set to ourself
if (this != &color_)
{
// Copy pixel value
*_pixel=*color_._pixel;
// Validity
_isValid=color_._isValid;
// Copy pixel type
_pixelType=color_._pixelType;
}
return(*this);
}

## operator=() [3/3]

const Magick::Color & Magick::Color::operator= | ( | const std::string & | color | ) |

Definition at line 223 of file Color.cpp.

{
PixelInfo
target_color;
initPixel();
GetPPException;
if (QueryColorCompliance(color_.c_str(),AllCompliance,&target_color,
exceptionInfo))
{
quantumAlpha((Magick::Quantum ) target_color.alpha);
quantumBlack((Magick::Quantum ) target_color.black);
quantumBlue((Magick::Quantum ) target_color.blue);
quantumGreen((Magick::Quantum ) target_color.green);
quantumRed((Magick::Quantum ) target_color.red);
setPixelType(target_color);
}
else
{
_isValid = false;
_pixelOwn = false;
delete _pixel;
_pixel = (PixelInfo *)NULL;
}
ThrowPPException(false);
return(*this);
}

## pixel()

void Magick::Color::pixel | ( | PixelInfo * | rep_,
|  | PixelType | pixelType_ )

protected

Definition at line 394 of file Color.cpp.

{
if (_pixelOwn)
delete _pixel;
_pixel=rep_;
_pixelOwn=false;
_isValid=true;
_pixelType=pixelType_;
}

## pixelType()

Magick::Color::PixelType Magick::Color::pixelType | ( | void |  | ) | const

Definition at line 301 of file Color.cpp.

{
return(_pixelType);
}

## quantumAlpha()

Magick::Quantum Magick::Color::quantumAlpha | ( | void |  | ) | const

Definition at line 328 of file Color.cpp.

{
return((Magick::Quantum) _pixel->alpha);
}

## quantumBlack()

Magick::Quantum Magick::Color::quantumBlack | ( | void |  | ) | const

Definition at line 339 of file Color.cpp.

{
return((Magick::Quantum) _pixel->black);
}

## quantumBlue()

Magick::Quantum Magick::Color::quantumBlue | ( | void |  | ) | const

Definition at line 350 of file Color.cpp.

{
return((Magick::Quantum) _pixel->blue);
}

## quantumGreen()

Magick::Quantum Magick::Color::quantumGreen | ( | void |  | ) | const

Definition at line 361 of file Color.cpp.

{
return((Magick::Quantum) _pixel->green);
}

## quantumRed()

Magick::Quantum Magick::Color::quantumRed | ( | void |  | ) | const

Definition at line 372 of file Color.cpp.

{
return((Magick::Quantum) _pixel->red);
}

## scaleDoubleToQuantum()

Magick::Quantum Magick::Color::scaleDoubleToQuantum | ( | const double | double_ | ) |

static protected

Definition at line 405 of file Color.cpp.

{
return(static_cast<Magick::Quantum>(double_*(double) QuantumRange));
}

## scaleQuantumToDouble()

double Magick::Color::scaleQuantumToDouble | ( | const Quantum | quantum_ | ) |

static protected

Definition at line 410 of file Color.cpp.

{
#if (MAGICKCORE_QUANTUM_DEPTH < 32) && (MAGICKCORE_SIZEOF_FLOAT_T != MAGICKCORE_SIZEOF_DOUBLE || !defined(MAGICKCORE_HDRI_SUPPORT))
return(static_cast<double>(QuantumScale*(double) quantum_));
#else
return(QuantumScale*quantum_);
#endif
}

## setAlpha()

void Magick::Color::setAlpha | ( | const Magick::Quantum | alpha_ | ) |

private

Definition at line 426 of file Color.cpp.

{
_pixel->alpha=alpha_;
if (alpha_ == OpaqueAlpha)
{
_pixel->alpha_trait=UndefinedPixelTrait;
if (_pixelType == RGBAPixel)
_pixelType=RGBPixel;
else if (_pixelType == CMYKAPixel)
_pixelType=CMYKPixel;
}
else
{
_pixel->alpha_trait=BlendPixelTrait;
if (_pixelType == RGBPixel)
_pixelType=RGBAPixel;
else if (_pixelType == CMYKPixel)
_pixelType=CMYKAPixel;
}
}

## setPixelType()

void Magick::Color::setPixelType | ( | const PixelInfo & | color_ | ) |

private

Definition at line 447 of file Color.cpp.

{
if (color_.colorspace == CMYKColorspace)
_pixelType=color_.alpha_trait != UndefinedPixelTrait ? CMYKAPixel :
CMYKPixel;
else
_pixelType=color_.alpha_trait != UndefinedPixelTrait ? RGBAPixel :
RGBPixel;
}

## Field Documentation

## _isValid

bool Magick::Color::_isValid

private

Definition at line 178 of file Color.h.

## _pixel

PixelInfo* Magick::Color::_pixel

protected

Definition at line 174 of file Color.h.

## _pixelOwn

bool Magick::Color::_pixelOwn

private

Definition at line 179 of file Color.h.

## _pixelType

PixelType Magick::Color::_pixelType

private

Definition at line 180 of file Color.h.

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

- Color.h
- Color.cpp