Magick++ 7.1.2-32
Convert, Edit, Or Compose Bitmap Images
Loading...
Searching...
No Matches
Magick::Color Class Reference
Inheritance diagram for Magick::Color:
Magick::ColorCMYK Magick::ColorGray Magick::ColorHSL Magick::ColorMono Magick::ColorRGB Magick::ColorYUV

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.

62 {
63 CMYKPixel,
64 CMYKAPixel,
65 RGBPixel,
66 RGBAPixel
67 };

Constructor & Destructor Documentation

◆ Color() [1/9]

Magick::Color::Color ( void )

Definition at line 76 of file Color.cpp.

77 : _pixel(new PixelInfo),
78 _isValid(false),
79 _pixelOwn(true),
80 _pixelType(RGBAPixel)
81{
82 initPixel();
83
84 setAlpha(TransparentAlpha);
85}

◆ 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 103 of file Color.cpp.

105 : _pixel(new PixelInfo),
106 _isValid(true),
107 _pixelOwn(true),
108 _pixelType(RGBPixel)
109{
110 initPixel();
111
112 quantumAlpha(alpha_);
113 quantumBlack(0);
114 quantumBlue(blue_);
115 quantumGreen(green_);
116 quantumRed(red_);
117 if (alpha_ != OpaqueAlpha)
118 _pixelType=RGBAPixel;
119}

◆ 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 121 of file Color.cpp.

124 : _pixel(new PixelInfo),
125 _isValid(true),
126 _pixelOwn(true),
127 _pixelType(CMYKPixel)
128{
129 initPixel();
130
131 quantumAlpha(alpha_);
132 quantumBlack(black_);
133 quantumBlue(yellow_);
134 quantumGreen(magenta_);
135 quantumRed(cyan_);
136 if (alpha_ != OpaqueAlpha)
137 _pixelType=CMYKAPixel;
138}

◆ Color() [4/9]

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

Definition at line 140 of file Color.cpp.

141 : _pixel(new PixelInfo),
142 _isValid(true),
143 _pixelOwn(true),
144 _pixelType(RGBPixel)
145{
146 initPixel();
147
148 // Use operator = implementation
149 try
150 {
151 *this=color_;
152 }
153 catch (...)
154 {
155 if (_pixelOwn)
156 delete _pixel;
157 _pixel=(PixelInfo *)NULL;
158 throw;
159 }
160}

◆ Color() [5/9]

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

Definition at line 162 of file Color.cpp.

163 : _pixel(new PixelInfo),
164 _isValid(color_._isValid),
165 _pixelOwn(true),
166 _pixelType(color_._pixelType)
167{
168 *_pixel=*color_._pixel;
169}

◆ Color() [6/9]

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

Definition at line 171 of file Color.cpp.

172 : _pixel(new PixelInfo),
173 _isValid(true),
174 _pixelOwn(true)
175{
176 *_pixel=color_;
177 setPixelType(color_);
178}

◆ Color() [7/9]

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

Definition at line 180 of file Color.cpp.

181 : _pixel(new PixelInfo),
182 _isValid(true),
183 _pixelOwn(true),
184 _pixelType(RGBPixel)
185{
186 initPixel();
187
188 // Use operator = implementation
189 try
190 {
191 *this=color_;
192 }
193 catch (...)
194 {
195 if (_pixelOwn)
196 delete _pixel;
197 _pixel=(PixelInfo *)NULL;
198 throw;
199 }
200}

◆ ~Color()

Magick::Color::~Color ( void )
virtual

Definition at line 202 of file Color.cpp.

203{
204 if (_pixelOwn)
205 delete _pixel;
206
207 _pixel=(PixelInfo *)NULL;
208}

◆ Color() [8/9]

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

Definition at line 404 of file Color.cpp.

405 : _pixel(rep_),
406 _isValid(true),
407 _pixelOwn(false),
408 _pixelType(pixelType_)
409{
410}

◆ Color() [9/9]

Magick::Color::Color ( PixelType pixelType_)
protected

Definition at line 395 of file Color.cpp.

396 : _pixel(new PixelInfo),
397 _isValid(false),
398 _pixelOwn(true),
399 _pixelType(pixelType_)
400{
401 initPixel();
402}

Member Function Documentation

◆ initPixel()

void Magick::Color::initPixel ( )
private

Definition at line 437 of file Color.cpp.

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

◆ isFuzzyEquivalent()

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

Definition at line 301 of file Color.cpp.

302{
303 PixelInfo
304 p,
305 q;
306
307 p=*_pixel;
308 p.fuzz=fuzz_;
309 q=*color_._pixel;
310 q.fuzz=fuzz_;
311 return (IsFuzzyEquivalencePixelInfo(&p, &q) != MagickFalse);
312}

◆ isValid() [1/2]

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

Definition at line 324 of file Color.cpp.

325{
326 if (bool(valid_) == bool(isValid()))
327 return;
328
329 if (!_pixelOwn)
330 {
331 _pixel=new PixelInfo;
332 _pixelOwn=true;
333 }
334
335 _isValid=valid_;
336
337 initPixel();
338}

◆ isValid() [2/2]

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

Definition at line 314 of file Color.cpp.

315{
316 return(_isValid);
317}

◆ operator std::string()

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

Definition at line 276 of file Color.cpp.

277{
278 char
279 colorbuf[MagickPathExtent];
280
281 PixelInfo
282 pixel;
283
284 if (!isValid())
285 return std::string("none");
286
287 pixel.colorspace=(_pixelType == RGBPixel || _pixelType == RGBAPixel) ?
288 sRGBColorspace : CMYKColorspace;
289 pixel.depth=MAGICKCORE_QUANTUM_DEPTH;
290 pixel.alpha=_pixel->alpha;
291 pixel.alpha_trait=_pixel->alpha_trait;
292 pixel.black=_pixel->black;
293 pixel.blue=_pixel->blue;
294 pixel.green=_pixel->green;
295 pixel.red=_pixel->red;
296 GetColorTuple(&pixel,MagickTrue,colorbuf);
297
298 return(std::string(colorbuf));
299}

◆ operator=() [1/3]

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

Definition at line 227 of file Color.cpp.

228{
229 *this=std::string(color_);
230 return(*this);
231}

◆ operator=() [2/3]

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

Definition at line 210 of file Color.cpp.

211{
212 // If not being set to ourself
213 if (this != &color_)
214 {
215 // Copy pixel value
216 *_pixel=*color_._pixel;
217
218 // Validity
219 _isValid=color_._isValid;
220
221 // Copy pixel type
222 _pixelType=color_._pixelType;
223 }
224 return(*this);
225}

◆ operator=() [3/3]

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

Definition at line 241 of file Color.cpp.

242{
243 PixelInfo
244 target_color;
245
246 initPixel();
247 GetPPException;
248 if (QueryColorCompliance(color_.c_str(),AllCompliance,&target_color,
249 exceptionInfo))
250 {
251 quantumAlpha((Magick::Quantum ) target_color.alpha);
252 quantumBlack((Magick::Quantum ) target_color.black);
253 quantumBlue((Magick::Quantum ) target_color.blue);
254 quantumGreen((Magick::Quantum ) target_color.green);
255 quantumRed((Magick::Quantum ) target_color.red);
256
257 setPixelType(target_color);
258 }
259 else
260 {
261 _isValid = false;
262 _pixelOwn = false;
263 delete _pixel;
264 _pixel = (PixelInfo *)NULL;
265 }
266 ThrowPPException(true);
267
268 return(*this);
269}

◆ pixel()

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

Definition at line 412 of file Color.cpp.

413{
414 if (_pixelOwn)
415 delete _pixel;
416
417 _pixel=rep_;
418 _pixelOwn=false;
419 _isValid=true;
420 _pixelType=pixelType_;
421}

◆ pixelType()

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

Definition at line 319 of file Color.cpp.

320{
321 return(_pixelType);
322}

◆ quantumAlpha()

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

Definition at line 346 of file Color.cpp.

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

◆ quantumBlack()

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

Definition at line 357 of file Color.cpp.

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

◆ quantumBlue()

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

Definition at line 368 of file Color.cpp.

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

◆ quantumGreen()

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

Definition at line 379 of file Color.cpp.

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

◆ quantumRed()

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

Definition at line 390 of file Color.cpp.

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

◆ scaleDoubleToQuantum()

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

Definition at line 423 of file Color.cpp.

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

◆ scaleQuantumToDouble()

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

Definition at line 428 of file Color.cpp.

429{
430#if (MAGICKCORE_QUANTUM_DEPTH < 32) && (MAGICKCORE_SIZEOF_FLOAT_T != MAGICKCORE_SIZEOF_DOUBLE || !defined(MAGICKCORE_HDRI_SUPPORT))
431 return(static_cast<double>(QuantumScale*(double) quantum_));
432#else
433 return(QuantumScale*quantum_);
434#endif
435}

◆ setAlpha()

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

Definition at line 444 of file Color.cpp.

445{
446 _pixel->alpha=alpha_;
447 if (alpha_ == OpaqueAlpha)
448 {
449 _pixel->alpha_trait=UndefinedPixelTrait;
450 if (_pixelType == RGBAPixel)
451 _pixelType=RGBPixel;
452 else if (_pixelType == CMYKAPixel)
453 _pixelType=CMYKPixel;
454 }
455 else
456 {
457 _pixel->alpha_trait=BlendPixelTrait;
458 if (_pixelType == RGBPixel)
459 _pixelType=RGBAPixel;
460 else if (_pixelType == CMYKPixel)
461 _pixelType=CMYKAPixel;
462 }
463}

◆ setPixelType()

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

Definition at line 465 of file Color.cpp.

466{
467 if (color_.colorspace == CMYKColorspace)
468 _pixelType=color_.alpha_trait != UndefinedPixelTrait ? CMYKAPixel :
469 CMYKPixel;
470 else
471 _pixelType=color_.alpha_trait != UndefinedPixelTrait ? RGBAPixel :
472 RGBPixel;
473}

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:
  • /home/cristy/Attic/Build/ImageMagick-7.1.2/rpmbuild/BUILD/ImageMagick-7.1.2-build/ImageMagick-7.1.2-32/Magick++/lib/Magick++/Color.h
  • /home/cristy/Attic/Build/ImageMagick-7.1.2/rpmbuild/BUILD/ImageMagick-7.1.2-build/ImageMagick-7.1.2-32/Magick++/lib/Color.cpp