Magick++ 7.1.1
Loading...
Searching...
No Matches
Magick::Color Class Reference
Inheritance diagram for Magick::Color:
Collaboration 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_)
 
Coloroperator= (const Color &color_)
 
const Coloroperator= (const char *color)
 
const Coloroperator= (const PixelInfo &color_)
 
const Coloroperator= (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/10]

Magick::Color::Color ( void  )

Definition at line 78 of file Color.cpp.

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

◆ Color() [2/10]

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

Definition at line 89 of file Color.cpp.

91 : _pixel(new PixelInfo),
92 _isValid(true),
93 _pixelOwn(true),
94 _pixelType(RGBPixel)
95{
96 initPixel();
97
98 quantumAlpha(OpaqueAlpha);
99 quantumBlack(0);
100 quantumBlue(blue_);
101 quantumGreen(green_);
102 quantumRed(red_);
103}

◆ Color() [3/10]

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.

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

◆ Color() [4/10]

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.

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

◆ Color() [5/10]

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

Definition at line 142 of file Color.cpp.

143 : _pixel(new PixelInfo),
144 _isValid(true),
145 _pixelOwn(true),
146 _pixelType(RGBPixel)
147{
148 initPixel();
149
150 // Use operator = implementation
151 *this=color_;
152}

◆ Color() [6/10]

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

Definition at line 154 of file Color.cpp.

155 : _pixel(new PixelInfo),
156 _isValid(color_._isValid),
157 _pixelOwn(true),
158 _pixelType(color_._pixelType)
159{
160 *_pixel=*color_._pixel;
161}

◆ Color() [7/10]

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

Definition at line 163 of file Color.cpp.

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

◆ Color() [8/10]

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

Definition at line 172 of file Color.cpp.

173 : _pixel(new PixelInfo),
174 _isValid(true),
175 _pixelOwn(true),
176 _pixelType(RGBPixel)
177{
178 initPixel();
179
180 // Use operator = implementation
181 *this=color_;
182}

◆ ~Color()

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

Definition at line 184 of file Color.cpp.

185{
186 if (_pixelOwn)
187 delete _pixel;
188
189 _pixel=(PixelInfo *)NULL;
190}

◆ Color() [9/10]

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

Definition at line 386 of file Color.cpp.

387 : _pixel(rep_),
388 _isValid(true),
389 _pixelOwn(false),
390 _pixelType(pixelType_)
391{
392}

◆ Color() [10/10]

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

Definition at line 377 of file Color.cpp.

378 : _pixel(new PixelInfo),
379 _isValid(false),
380 _pixelOwn(true),
381 _pixelType(pixelType_)
382{
383 initPixel();
384}

Member Function Documentation

◆ initPixel()

void Magick::Color::initPixel ( )
private

Definition at line 419 of file Color.cpp.

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

◆ isFuzzyEquivalent()

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

Definition at line 283 of file Color.cpp.

284{
285 PixelInfo
286 p,
287 q;
288
289 p=*_pixel;
290 p.fuzz=fuzz_;
291 q=*color_._pixel;
292 q.fuzz=fuzz_;
293 return (IsFuzzyEquivalencePixelInfo(&p, &q) != MagickFalse);
294}

◆ isValid() [1/2]

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

Definition at line 306 of file Color.cpp.

307{
308 if (bool(valid_) == bool(isValid()))
309 return;
310
311 if (!_pixelOwn)
312 {
313 _pixel=new PixelInfo;
314 _pixelOwn=true;
315 }
316
317 _isValid=valid_;
318
319 initPixel();
320}

◆ isValid() [2/2]

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

Definition at line 296 of file Color.cpp.

297{
298 return(_isValid);
299}

◆ operator std::string()

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

Definition at line 258 of file Color.cpp.

259{
260 char
261 colorbuf[MagickPathExtent];
262
263 PixelInfo
264 pixel;
265
266 if (!isValid())
267 return std::string("none");
268
269 pixel.colorspace=(_pixelType == RGBPixel || _pixelType == RGBAPixel) ?
270 sRGBColorspace : CMYKColorspace;
271 pixel.depth=MAGICKCORE_QUANTUM_DEPTH;
272 pixel.alpha=_pixel->alpha;
273 pixel.alpha_trait=_pixel->alpha_trait;
274 pixel.black=_pixel->black;
275 pixel.blue=_pixel->blue;
276 pixel.green=_pixel->green;
277 pixel.red=_pixel->red;
278 GetColorTuple(&pixel,MagickTrue,colorbuf);
279
280 return(std::string(colorbuf));
281}

◆ operator=() [1/3]

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

Definition at line 209 of file Color.cpp.

210{
211 *this=std::string(color_);
212 return(*this);
213}

◆ operator=() [2/3]

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

Definition at line 192 of file Color.cpp.

193{
194 // If not being set to ourself
195 if (this != &color_)
196 {
197 // Copy pixel value
198 *_pixel=*color_._pixel;
199
200 // Validity
201 _isValid=color_._isValid;
202
203 // Copy pixel type
204 _pixelType=color_._pixelType;
205 }
206 return(*this);
207}

◆ operator=() [3/3]

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

Definition at line 223 of file Color.cpp.

224{
225 PixelInfo
226 target_color;
227
228 initPixel();
229 GetPPException;
230 if (QueryColorCompliance(color_.c_str(),AllCompliance,&target_color,
231 exceptionInfo))
232 {
233 quantumAlpha(target_color.alpha);
234 quantumBlack(target_color.black);
235 quantumBlue(target_color.blue);
236 quantumGreen(target_color.green);
237 quantumRed(target_color.red);
238
239 setPixelType(target_color);
240 }
241 else
242 {
243 _isValid = false;
244 _pixelOwn = false;
245 delete _pixel;
246 _pixel = (PixelInfo *)NULL;
247 }
248 ThrowPPException(false);
249
250 return(*this);
251}

◆ pixel()

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

Definition at line 394 of file Color.cpp.

395{
396 if (_pixelOwn)
397 delete _pixel;
398
399 _pixel=rep_;
400 _pixelOwn=false;
401 _isValid=true;
402 _pixelType=pixelType_;
403}

◆ pixelType()

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

Definition at line 301 of file Color.cpp.

302{
303 return(_pixelType);
304}

◆ quantumAlpha() [1/2]

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

Definition at line 322 of file Color.cpp.

323{
324 setAlpha(alpha_);
325 _isValid=true;
326}

◆ quantumAlpha() [2/2]

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

Definition at line 328 of file Color.cpp.

329{
330 return(_pixel->alpha);
331}

◆ quantumBlack() [1/2]

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

Definition at line 333 of file Color.cpp.

334{
335 _pixel->black=black_;
336 _isValid=true;
337}

◆ quantumBlack() [2/2]

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

Definition at line 339 of file Color.cpp.

340{
341 return(_pixel->black);
342}

◆ quantumBlue() [1/2]

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

Definition at line 344 of file Color.cpp.

345{
346 _pixel->blue=blue_;
347 _isValid=true;
348}

◆ quantumBlue() [2/2]

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

Definition at line 350 of file Color.cpp.

351{
352 return(_pixel->blue);
353}

◆ quantumGreen() [1/2]

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

Definition at line 355 of file Color.cpp.

356{
357 _pixel->green=green_;
358 _isValid=true;
359}

◆ quantumGreen() [2/2]

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

Definition at line 361 of file Color.cpp.

362{
363 return(_pixel->green);
364}

◆ quantumRed() [1/2]

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

Definition at line 366 of file Color.cpp.

367{
368 _pixel->red=red_;
369 _isValid=true;
370}

◆ quantumRed() [2/2]

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

Definition at line 372 of file Color.cpp.

373{
374 return _pixel->red;
375}

◆ scaleDoubleToQuantum()

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

Definition at line 405 of file Color.cpp.

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

◆ scaleQuantumToDouble()

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

Definition at line 410 of file Color.cpp.

411{
412#if (MAGICKCORE_QUANTUM_DEPTH < 32) && (MAGICKCORE_SIZEOF_FLOAT_T != MAGICKCORE_SIZEOF_DOUBLE || !defined(MAGICKCORE_HDRI_SUPPORT))
413 return(static_cast<double>(QuantumScale*(double) quantum_));
414#else
415 return(QuantumScale*quantum_);
416#endif
417}

◆ setAlpha()

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

Definition at line 426 of file Color.cpp.

427{
428 _pixel->alpha=alpha_;
429 if (alpha_ == OpaqueAlpha)
430 {
431 _pixel->alpha_trait=UndefinedPixelTrait;
432 if (_pixelType == RGBAPixel)
433 _pixelType=RGBPixel;
434 else if (_pixelType == CMYKAPixel)
435 _pixelType=CMYKPixel;
436 }
437 else
438 {
439 _pixel->alpha_trait=BlendPixelTrait;
440 if (_pixelType == RGBPixel)
441 _pixelType=RGBAPixel;
442 else if (_pixelType == CMYKPixel)
443 _pixelType=CMYKAPixel;
444 }
445}

◆ setPixelType()

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

Definition at line 447 of file Color.cpp.

448{
449 if (color_.colorspace == CMYKColorspace)
450 _pixelType=color_.alpha_trait != UndefinedPixelTrait ? CMYKAPixel :
451 CMYKPixel;
452 else
453 _pixelType=color_.alpha_trait != UndefinedPixelTrait ? RGBAPixel :
454 RGBPixel;
455}

Member Data 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: