Magick++ 7.1.0

Color.cpp
Go to the documentation of this file.
1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
4 //
5 // Copyright @ 2013 ImageMagick Studio LLC, a non-profit organization
6 // dedicated to making software imaging solutions freely available.
7 //
8 // Color Implementation
9 //
10
11 #define MAGICKCORE_IMPLEMENTATION
12 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
13
14 #include "Magick++/Include.h"
15 #include <string>
16
17 #include "Magick++/Color.h"
18 #include "Magick++/Exception.h"
19
20 using namespace std;
21
22 MagickPPExport int Magick::operator == (const Magick::Color &left_,
23 const Magick::Color &right_)
24 {
25 #if defined(MAGICKCORE_HDRI_SUPPORT)
26 return((left_.isValid() == right_.isValid()) &&
27 (fabs(left_.quantumRed()-right_.quantumRed()) < MagickEpsilon) &&
28 (fabs(left_.quantumGreen()-right_.quantumGreen()) < MagickEpsilon) &&
29 (fabs(left_.quantumBlue()-right_.quantumBlue()) < MagickEpsilon));
30 #else
31 return((left_.isValid() == right_.isValid()) &&
32 (left_.quantumRed() == right_.quantumRed()) &&
33 (left_.quantumGreen() == right_.quantumGreen()) &&
34 (left_.quantumBlue() == right_.quantumBlue()));
35 #endif
36 }
37
38 MagickPPExport int Magick::operator != (const Magick::Color &left_,
39 const Magick::Color &right_)
40 {
41 return(!(left_ == right_));
42 }
43
44 MagickPPExport int Magick::operator > (const Magick::Color &left_,
45 const Magick::Color &right_)
46 {
47 return(!(left_ < right_ ) && (left_ != right_ ));
48 }
49
50 MagickPPExport int Magick::operator < ( const Magick::Color &left_,
51 const Magick::Color &right_)
52 {
53 if(left_.quantumRed() < right_.quantumRed())
54 return(true);
55 if(left_.quantumRed() > right_.quantumRed())
56 return(false);
57 if(left_.quantumGreen() < right_.quantumGreen())
58 return(true);
59 if(left_.quantumGreen() > right_.quantumGreen())
60 return(false);
61 if(left_.quantumBlue() < right_.quantumBlue())
62 return(true);
63 return(false);
64 }
65
66 MagickPPExport int Magick::operator >= (const Magick::Color &left_,
67 const Magick::Color &right_)
68 {
69 return((left_ > right_) || (left_ == right_));
70 }
71
72 MagickPPExport int Magick::operator <= ( const Magick::Color &left_,
73 const Magick::Color &right_)
74 {
75 return((left_ < right_) || (left_ == right_));
76 }
77
78 Magick::Color::Color(void)
79 : _pixel(new PixelInfo),
80 _isValid(false),
81 _pixelOwn(true),
82 _pixelType(RGBAPixel)
83 {
84 initPixel();
85
86 setAlpha(TransparentAlpha);
87 }
88
89 Magick::Color::Color(const Magick::Quantum red_,const Magick::Quantum green_,
90 const Quantum blue_)
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 }
104
105 Magick::Color::Color(const Magick::Quantum red_,const Magick::Quantum green_,
106 const Magick::Quantum blue_, const Magick::Quantum alpha_)
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 }
122
123 Magick::Color::Color(const Magick::Quantum cyan_,const Magick::Quantum magenta_,
124 const Magick::Quantum yellow_,const Magick::Quantum black_,
125 const Magick::Quantum alpha_)
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 }
141
142 Magick::Color::Color(const char *color_)
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 }
153
154 Magick::Color::Color(const Magick::Color &color_)
155 : _pixel(new PixelInfo),
156 _isValid(color_._isValid),
157 _pixelOwn(true),
158 _pixelType(color_._pixelType)
159 {
160 *_pixel=*color_._pixel;
161 }
162
163 Magick::Color::Color(const PixelInfo &color_)
164 : _pixel(new PixelInfo),
165 _isValid(true),
166 _pixelOwn(true)
167 {
168 *_pixel=color_;
169 setPixelType(color_);
170 }
171
172 Magick::Color::Color(const std::string &color_)
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 }
183
184 Magick::Color::~Color(void)
185 {
186 if (_pixelOwn)
187 delete _pixel;
188
189 _pixel=(PixelInfo *)NULL;
190 }
191
192 Magick::Color& Magick::Color::operator=(const Magick::Color& color_)
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 }
208
209 const Magick::Color& Magick::Color::operator=(const char *color_)
210 {
211 *this=std::string(color_);
212 return(*this);
213 }
214
215 const Magick::Color& Magick::Color::operator=(const MagickCore::PixelInfo &color_)
216 {
217 *_pixel=color_;
218 setPixelType(color_);
219
220 return(*this);
221 }
222
223 const Magick::Color& Magick::Color::operator=(const std::string &color_)
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 _isValid = false;
243 ThrowPPException(false);
244
245 return(*this);
246 }
247
248 Magick::Color::operator MagickCore::PixelInfo() const
249 {
250 return *_pixel;
251 }
252
253 Magick::Color::operator std::string() const
254 {
255 char
256 colorbuf[MagickPathExtent];
257
258 PixelInfo
259 pixel;
260
261 if (!isValid())
262 return std::string("none");
263
264 pixel.colorspace=(_pixelType == RGBPixel || _pixelType == RGBAPixel) ?
265 sRGBColorspace : CMYKColorspace;
266 pixel.depth=MAGICKCORE_QUANTUM_DEPTH;
267 pixel.alpha=_pixel->alpha;
268 pixel.alpha_trait=_pixel->alpha_trait;
269 pixel.black=_pixel->black;
270 pixel.blue=_pixel->blue;
271 pixel.green=_pixel->green;
272 pixel.red=_pixel->red;
273 GetColorTuple(&pixel,MagickTrue,colorbuf);
274
275 return(std::string(colorbuf));
276 }
277
278 bool Magick::Color::isFuzzyEquivalent(const Color &color_, const double fuzz_) const
279 {
280 PixelInfo
281 p,
282 q;
283
284 p=*_pixel;
285 p.fuzz=fuzz_;
286 q=*color_._pixel;
287 q.fuzz=fuzz_;
288 return (IsFuzzyEquivalencePixelInfo(&p, &q) != MagickFalse);
289 }
290
291 bool Magick::Color::isValid(void) const
292 {
293 return(_isValid);
294 }
295
296 Magick::Color::PixelType Magick::Color::pixelType() const
297 {
298 return(_pixelType);
299 }
300
301 void Magick::Color::isValid(bool valid_)
302 {
303 if (bool(valid_) == bool(isValid()))
304 return;
305
306 if (!_pixelOwn)
307 {
308 _pixel=new PixelInfo;
309 _pixelOwn=true;
310 }
311
312 _isValid=valid_;
313
314 initPixel();
315 }
316
317 void Magick::Color::quantumAlpha(const Magick::Quantum alpha_)
318 {
319 setAlpha(alpha_);
320 _isValid=true;
321 }
322
323 Magick::Quantum Magick::Color::quantumAlpha(void) const
324 {
325 return(_pixel->alpha);
326 }
327
328 void Magick::Color::quantumBlack(const Magick::Quantum black_)
329 {
330 _pixel->black=black_;
331 _isValid=true;
332 }
333
334 Magick::Quantum Magick::Color::quantumBlack(void) const
335 {
336 return(_pixel->black);
337 }
338
339 void Magick::Color::quantumBlue(const Magick::Quantum blue_)
340 {
341 _pixel->blue=blue_;
342 _isValid=true;
343 }
344
345 Magick::Quantum Magick::Color::quantumBlue(void) const
346 {
347 return(_pixel->blue);
348 }
349
350 void Magick::Color::quantumGreen(const Magick::Quantum green_)
351 {
352 _pixel->green=green_;
353 _isValid=true;
354 }
355
356 Magick::Quantum Magick::Color::quantumGreen(void) const
357 {
358 return(_pixel->green);
359 }
360
361 void Magick::Color::quantumRed(const Magick::Quantum red_)
362 {
363 _pixel->red=red_;
364 _isValid=true;
365 }
366
367 Magick::Quantum Magick::Color::quantumRed(void) const
368 {
369 return _pixel->red;
370 }
371
372 Magick::Color::Color(PixelType pixelType_)
373 : _pixel(new PixelInfo),
374 _isValid(false),
375 _pixelOwn(true),
376 _pixelType(pixelType_)
377 {
378 initPixel();
379 }
380
381 Magick::Color::Color(PixelInfo* rep_,PixelType pixelType_)
382 : _pixel(rep_),
383 _isValid(true),
384 _pixelOwn(false),
385 _pixelType(pixelType_)
386 {
387 }
388
389 void Magick::Color::pixel(PixelInfo *rep_,PixelType pixelType_)
390 {
391 if (_pixelOwn)
392 delete _pixel;
393
394 _pixel=rep_;
395 _pixelOwn=false;
396 _isValid=true;
397 _pixelType=pixelType_;
398 }
399
400 Magick::Quantum Magick::Color::scaleDoubleToQuantum(const double double_)
401 {
402 return(static_cast<Magick::Quantum>(double_*QuantumRange));
403 }
404
405 double Magick::Color::scaleQuantumToDouble(const Magick::Quantum quantum_)
406 {
407 #if (MAGICKCORE_QUANTUM_DEPTH < 32) && (MAGICKCORE_SIZEOF_FLOAT_T != MAGICKCORE_SIZEOF_DOUBLE || !defined(MAGICKCORE_HDRI_SUPPORT))
408 return(static_cast<double>(QuantumScale*quantum_));
409 #else
410 return(QuantumScale*quantum_);
411 #endif
412 }
413
414 void Magick::Color::initPixel()
415 {
416 MagickCore::GetPixelInfo((MagickCore::Image *) NULL, _pixel);
417 if (_pixelType == CMYKPixel || _pixelType == CMYKAPixel)
418 _pixel->colorspace=CMYKColorspace;
419 }
420
421 void Magick::Color::setAlpha(const Magick::Quantum alpha_)
422 {
423 _pixel->alpha=alpha_;
424 if (alpha_ == OpaqueAlpha)
425 {
426 _pixel->alpha_trait=UndefinedPixelTrait;
427 if (_pixelType == RGBAPixel)
428 _pixelType=RGBPixel;
429 else if (_pixelType == CMYKAPixel)
430 _pixelType=CMYKPixel;
431 }
432 else
433 {
434 _pixel->alpha_trait=BlendPixelTrait;
435 if (_pixelType == RGBPixel)
436 _pixelType=RGBAPixel;
437 else if (_pixelType == CMYKPixel)
438 _pixelType=CMYKAPixel;
439 }
440 }
441
442 void Magick::Color::setPixelType(const PixelInfo &color_)
443 {
444 if (color_.colorspace == CMYKColorspace)
445 _pixelType=color_.alpha_trait != UndefinedPixelTrait ? CMYKAPixel :
446 CMYKPixel;
447 else
448 _pixelType=color_.alpha_trait != UndefinedPixelTrait ? RGBAPixel :
449 RGBPixel;
450 }
451
452 Magick::ColorCMYK::ColorCMYK(void)
453 : Color(CMYKPixel)
454 {
455 }
456
457 Magick::ColorCMYK::ColorCMYK(const Magick::Color &color_)
458 : Color(color_)
459 {
460 }
461
462 Magick::ColorCMYK::ColorCMYK(const double cyan_,const double magenta_,
463 const double yellow_,const double black_)
464 : Color(CMYKPixel)
465 {
466 cyan(cyan_);
467 magenta(magenta_);
468 yellow(yellow_);
469 black(black_);
470 }
471
472 Magick::ColorCMYK::ColorCMYK(const double cyan_,const double magenta_,
473 const double yellow_,const double black_,const double alpha_)
474 : Color(CMYKAPixel)
475 {
476 cyan(cyan_);
477 magenta(magenta_);
478 yellow(yellow_);
479 black(black_);
480 alpha(alpha_);
481 }
482
483 Magick::ColorCMYK::~ColorCMYK(void)
484 {
485 }
486
487 Magick::ColorCMYK& Magick::ColorCMYK::operator=(const Magick::Color& color_)
488 {
489 *static_cast<Magick::Color*>(this)=color_;
490 return(*this);
491 }
492
493 void Magick::ColorCMYK::alpha(const double alpha_)
494 {
495 quantumAlpha(scaleDoubleToQuantum(alpha_));
496 }
497
498 double Magick::ColorCMYK::alpha(void) const
499 {
500 return(scaleQuantumToDouble(quantumAlpha()));
501 }
502
503 void Magick::ColorCMYK::black(const double black_)
504 {
505 quantumBlack(scaleDoubleToQuantum(black_));
506 }
507
508 double Magick::ColorCMYK::black(void) const
509 {
510 return(scaleQuantumToDouble(quantumBlack()));
511 }
512
513 void Magick::ColorCMYK::cyan(const double cyan_)
514 {
515 quantumRed(scaleDoubleToQuantum(cyan_));
516 }
517
518 double Magick::ColorCMYK::cyan(void) const
519 {
520 return(scaleQuantumToDouble(quantumRed()));
521 }
522
523 void Magick::ColorCMYK::magenta(const double magenta_)
524 {
525 quantumGreen(scaleDoubleToQuantum(magenta_));
526 }
527
528 double Magick::ColorCMYK::magenta(void) const
529 {
530 return(scaleQuantumToDouble(quantumGreen()));
531 }
532
533 void Magick::ColorCMYK::yellow(const double yellow_)
534 {
535 quantumBlue(scaleDoubleToQuantum(yellow_));
536 }
537
538 double Magick::ColorCMYK::yellow(void) const
539 {
540 return(scaleQuantumToDouble(quantumBlue()));
541 }
542
543 Magick::ColorCMYK::ColorCMYK(PixelInfo *rep_,PixelType pixelType_)
544 : Color(rep_,pixelType_)
545 {
546 }
547
548 Magick::ColorGray::ColorGray(void)
549 : Color(RGBPixel)
550 {
551 }
552
553 Magick::ColorGray::ColorGray(const Magick::Color & color_)
554 : Color(color_)
555 {
556 }
557
558 Magick::ColorGray::ColorGray(double shade_)
559 : Color(scaleDoubleToQuantum(shade_),scaleDoubleToQuantum(shade_),
560 scaleDoubleToQuantum(shade_))
561 {
562 }
563
564 Magick::ColorGray::~ColorGray()
565 {
566 }
567
568 void Magick::ColorGray::shade(double shade_)
569 {
570 Quantum gray=scaleDoubleToQuantum(shade_);
571 quantumRed(gray);
572 quantumGreen(gray);
573 quantumBlue(gray);
574 }
575
576 double Magick::ColorGray::shade(void) const
577 {
578 return(scaleQuantumToDouble(quantumGreen()));
579 }
580
581 Magick::ColorGray& Magick::ColorGray::operator=(const Magick::Color& color_)
582 {
583 *static_cast<Magick::Color*>(this)=color_;
584 return(*this);
585 }
586
587 Magick::ColorGray::ColorGray(PixelInfo *rep_,PixelType pixelType_)
588 : Color(rep_,pixelType_)
589 {
590 }
591
592 Magick::ColorHSL::ColorHSL(void)
593 : Color(RGBPixel)
594 {
595 }
596
597 Magick::ColorHSL::ColorHSL(const Magick::Color &color_)
598 : Color(color_)
599 {
600 }
601
602 Magick::ColorHSL::ColorHSL(const double hue_,const double saturation_,
603 const double lightness_)
604 : Color(RGBPixel)
605 {
606 double
607 blue,
608 green,
609 red;
610
611 ConvertHSLToRGB(hue_,saturation_,lightness_,&red,&green,&blue);
612
613 quantumRed(red);
614 quantumGreen(green);
615 quantumBlue(blue);
616 }
617
618 Magick::ColorHSL::~ColorHSL()
619 {
620 }
621
622 Magick::ColorHSL& Magick::ColorHSL::operator=(const Magick::Color& color_)
623 {
624 *static_cast<Magick::Color*>(this) = color_;
625 return(*this);
626 }
627
628 void Magick::ColorHSL::hue(const double hue_)
629 {
630 double
631 hue,
632 lightness,
633 saturation;
634
635 double
636 blue,
637 green,
638 red;
639
640 ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
641 &lightness);
642
643 hue=hue_;
644
645 ConvertHSLToRGB(hue,saturation,lightness,&red,&green,&blue);
646
647 quantumRed(ClampToQuantum(red));
648 quantumGreen(ClampToQuantum(green));
649 quantumBlue(ClampToQuantum(blue));
650 }
651
652 double Magick::ColorHSL::hue(void) const
653 {
654 double
655 hue,
656 lightness,
657 saturation;
658
659 ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
660 &lightness);
661
662 return(hue);
663 }
664
665 void Magick::ColorHSL::lightness (const double lightness_)
666 {
667 double
668 hue,
669 lightness,
670 saturation;
671
672 double
673 blue,
674 green,
675 red;
676
677 ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
678 &lightness);
679
680 lightness=lightness_;
681
682 ConvertHSLToRGB(hue,saturation,lightness,&red,&green,&blue);
683
684 quantumRed(ClampToQuantum(red));
685 quantumGreen(ClampToQuantum(green));
686 quantumBlue(ClampToQuantum(blue));
687 }
688
689 double Magick::ColorHSL::lightness (void) const
690 {
691 double
692 hue,
693 lightness,
694 saturation;
695
696 ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
697 &lightness);
698
699 return(lightness);
700 }
701
702 void Magick::ColorHSL::saturation(const double saturation_)
703 {
704 double
705 hue,
706 lightness,
707 saturation;
708
709 double
710 blue,
711 green,
712 red;
713
714 ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
715 &lightness);
716
717 saturation=saturation_;
718
719 ConvertHSLToRGB(hue,saturation,lightness,&red,&green,&blue);
720
721 quantumRed(ClampToQuantum(red));
722 quantumGreen(ClampToQuantum(green));
723 quantumBlue(ClampToQuantum(blue));
724 }
725
726 double Magick::ColorHSL::saturation(void) const
727 {
728 double
729 hue,
730 lightness,
731 saturation;
732
733 ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
734 &lightness);
735
736 return(saturation);
737 }
738
739 Magick::ColorMono::ColorMono(void)
740 : Color(RGBPixel)
741 {
742 }
743
744 Magick::ColorMono::ColorMono(const bool mono_)
745 : Color((mono_ ? QuantumRange : 0),(mono_ ? QuantumRange : 0),
746 (mono_ ? QuantumRange : 0))
747 {
748 }
749
750 Magick::ColorMono::ColorMono(const Magick::Color &color_)
751 : Color(color_)
752 {
753 }
754
755 Magick::ColorMono::~ColorMono()
756 {
757 }
758
759 Magick::ColorMono& Magick::ColorMono::operator=(const Magick::Color& color_)
760 {
761 *static_cast<Magick::Color*>(this)=color_;
762 return(*this);
763 }
764
765 void Magick::ColorMono::mono(bool mono_)
766 {
767 quantumRed(mono_ ? QuantumRange : 0);
768 quantumGreen(mono_ ? QuantumRange : 0);
769 quantumBlue(mono_ ? QuantumRange : 0);
770 }
771
772 bool Magick::ColorMono::mono(void) const
773 {
774 return(quantumGreen() == 0);
775 }
776
777 Magick::ColorMono::ColorMono(PixelInfo *rep_,PixelType pixelType_)
778 : Color(rep_,pixelType_)
779 {
780 }
781
782 Magick::ColorRGB::ColorRGB(void)
783 : Color(RGBPixel)
784 {
785 }
786
787 Magick::ColorRGB::ColorRGB(const Magick::Color &color_)
788 : Color(color_)
789 {
790 }
791
792 Magick::ColorRGB::ColorRGB(const double red_,const double green_,
793 const double blue_)
794 : Color(scaleDoubleToQuantum(red_),scaleDoubleToQuantum(green_),
795 scaleDoubleToQuantum(blue_))
796 {
797 }
798
799 Magick::ColorRGB::ColorRGB(const double red_,const double green_,
800 const double blue_,const double alpha_)
801 : Color(scaleDoubleToQuantum(red_),scaleDoubleToQuantum(green_),
802 scaleDoubleToQuantum(blue_),scaleDoubleToQuantum(alpha_))
803 {
804 }
805
806 Magick::ColorRGB::~ColorRGB(void)
807 {
808 }
809
810 Magick::ColorRGB& Magick::ColorRGB::operator=(const Magick::Color& color_)
811 {
812 *static_cast<Magick::Color*>(this)=color_;
813 return(*this);
814 }
815
816 void Magick::ColorRGB::alpha(const double alpha_)
817 {
818 quantumAlpha(scaleDoubleToQuantum(alpha_));
819 }
820
821 double Magick::ColorRGB::alpha(void) const
822 {
823 return(scaleQuantumToDouble(quantumAlpha()));
824 }
825
826 void Magick::ColorRGB::blue(const double blue_)
827 {
828 quantumBlue(scaleDoubleToQuantum(blue_));
829 }
830
831 double Magick::ColorRGB::blue(void) const
832 {
833 return(scaleQuantumToDouble(quantumBlue()));
834 }
835
836 void Magick::ColorRGB::green(const double green_)
837 {
838 quantumGreen(scaleDoubleToQuantum(green_));
839 }
840
841 double Magick::ColorRGB::green(void) const
842 {
843 return(scaleQuantumToDouble(quantumGreen()));
844 }
845
846 void Magick::ColorRGB::red(const double red_)
847 {
848 quantumRed(scaleDoubleToQuantum(red_));
849 }
850
851 double Magick::ColorRGB::red(void) const
852 {
853 return(scaleQuantumToDouble(quantumRed()));
854 }
855
856 Magick::ColorRGB::ColorRGB(PixelInfo *rep_,PixelType pixelType_)
857 : Color(rep_,pixelType_)
858 {
859 }
860
861 Magick::ColorYUV::ColorYUV(void)
862 : Color(RGBPixel)
863 {
864 }
865
866 Magick::ColorYUV::ColorYUV(const Magick::Color &color_)
867 : Color(color_)
868 {
869 }
870
871 Magick::ColorYUV::ColorYUV(const double y_,const double u_,const double v_)
872 : Color(RGBPixel)
873 {
874 convert(y_, u_, v_);
875 }
876
877 Magick::ColorYUV::~ColorYUV(void)
878 {
879 }
880
881 Magick::ColorYUV& Magick::ColorYUV::operator=(const Magick::Color &color_)
882 {
883 *static_cast<Magick::Color*>(this)=color_;
884 return(*this);
885 }
886
887 void Magick::ColorYUV::u(const double u_)
888 {
889 convert(y(), u_, v());
890 }
891
892 double Magick::ColorYUV::u(void) const
893 {
894 return(scaleQuantumToDouble((-0.14740 * quantumRed()) - (0.28950 *
895 quantumGreen()) + (0.43690 * quantumBlue())));
896 }
897
898 void Magick::ColorYUV::v(const double v_)
899 {
900 convert(y(), u(), v_);
901 }
902
903 double Magick::ColorYUV::v(void) const
904 {
905 return(scaleQuantumToDouble((0.61500 * quantumRed()) - (0.51500 *
906 quantumGreen()) - (0.10000 * quantumBlue())));
907 }
908
909 void Magick::ColorYUV::y(const double y_)
910 {
911 convert(y_, u(), v());
912 }
913
914 double Magick::ColorYUV::y ( void ) const
915 {
916 return(scaleQuantumToDouble((0.29900 * quantumRed()) + (0.58700 *
917 quantumGreen()) + (0.11400 * quantumBlue())));
918 }
919
920 void Magick::ColorYUV::convert(const double y_,const double u_,const double v_)
921 {
922 quantumRed(scaleDoubleToQuantum(y_ + 1.13980 * v_));
923 quantumGreen(scaleDoubleToQuantum(y_ - (0.39380 * u_) - (0.58050 * v_)));
924 quantumBlue(scaleDoubleToQuantum(y_ + 2.02790 * u_));
925 }
926
927 Magick::ColorYUV::ColorYUV(PixelInfo *rep_,PixelType pixelType_)
928 : Color(rep_,pixelType_)
929 {
930 }
Magick::ColorYUV::operator=
ColorYUV & operator=(const Color &color_)
Definition: Color.cpp:881
Magick::Color::RGBAPixel
Definition: Color.h:66
Magick::operator!=
MagickPPExport int operator!=(const Magick::Color &left_, const Magick::Color &right_)
Definition: Color.cpp:38
Magick::ColorCMYK::~ColorCMYK
~ColorCMYK(void)
Definition: Color.cpp:483
Magick::ColorRGB
Definition: Color.h:351
Magick::ColorGray::shade
double shade(void) const
Definition: Color.cpp:576
Magick::Color::quantumGreen
void quantumGreen(const Quantum green_)
Definition: Color.cpp:350
Magick::Color::quantumGreen
Quantum quantumGreen(void) const
Definition: Color.cpp:356
Magick::Color::quantumAlpha
Quantum quantumAlpha(void) const
Definition: Color.cpp:323
Magick::ColorRGB::~ColorRGB
~ColorRGB(void)
Definition: Color.cpp:806
Magick::ColorHSL::lightness
double lightness(void) const
Definition: Color.cpp:689
Magick::ColorYUV::ColorYUV
ColorYUV(void)
Definition: Color.cpp:861
Magick::Color::isValid
bool isValid(void) const
Definition: Color.cpp:291
Magick::Color::quantumBlue
Quantum quantumBlue(void) const
Definition: Color.cpp:345
std
STL namespace.
Magick::Color::quantumBlue
void quantumBlue(const Quantum blue_)
Definition: Color.cpp:339
Magick::ColorMono::~ColorMono
~ColorMono()
Definition: Color.cpp:755
Magick::ColorCMYK
Definition: Color.h:191
Magick::operator<
MagickPPExport int operator<(const Magick::Color &left_, const Magick::Color &right_)
Definition: Color.cpp:50
Magick::ColorYUV::u
double u(void) const
Definition: Color.cpp:892
Magick::Color::PixelType
PixelType
Definition: Color.h:61
Magick::ColorCMYK::black
double black(void) const
Definition: Color.cpp:508
Magick::ColorRGB::green
double green(void) const
Definition: Color.cpp:841
Magick::ColorRGB::alpha
double alpha(void) const
Definition: Color.cpp:821
Magick::ColorGray::operator=
ColorGray & operator=(const Color &color_)
Definition: Color.cpp:581
Magick::operator<=
MagickPPExport int operator<=(const Magick::Color &left_, const Magick::Color &right_)
Definition: Color.cpp:72
Magick::ColorRGB::ColorRGB
ColorRGB(void)
Definition: Color.cpp:782
Magick::operator>=
MagickPPExport int operator>=(const Magick::Color &left_, const Magick::Color &right_)
Definition: Color.cpp:66
Magick::ColorYUV
Definition: Color.h:403
Magick::ColorHSL::hue
double hue(void) const
Definition: Color.cpp:652
Magick::Color::quantumRed
Quantum quantumRed(void) const
Definition: Color.cpp:367
Magick::ColorHSL
Definition: Color.h:279
Magick::ColorCMYK::operator=
ColorCMYK & operator=(const Color &color_)
Definition: Color.cpp:487
MagickPPExport
#define MagickPPExport
Definition: Include.h:297
Magick::ColorCMYK::ColorCMYK
ColorCMYK(void)
Definition: Color.cpp:452
Magick::ColorRGB::operator=
ColorRGB & operator=(const Color &color_)
Definition: Color.cpp:810
Magick::ColorMono
Definition: Color.h:322
Magick::Color::quantumBlack
Quantum quantumBlack(void) const
Definition: Color.cpp:334
Magick::Color
Definition: Color.h:36
Magick::ColorRGB::blue
double blue(void) const
Definition: Color.cpp:831
Magick::ColorCMYK::cyan
double cyan(void) const
Definition: Color.cpp:518
Magick::ColorYUV::~ColorYUV
~ColorYUV(void)
Definition: Color.cpp:877
Magick::ColorHSL::saturation
double saturation(void) const
Definition: Color.cpp:726
ThrowPPException
#define ThrowPPException(quiet)
Definition: Include.h:1580
Magick::ColorHSL::ColorHSL
ColorHSL(void)
Definition: Color.cpp:592
Color.h
Magick::Color::scaleQuantumToDouble
static double scaleQuantumToDouble(const Quantum quantum_)
Definition: Color.cpp:405
Magick::ColorCMYK::yellow
double yellow(void) const
Definition: Color.cpp:538
Magick::ColorMono::mono
bool mono(void) const
Definition: Color.cpp:772
Include.h
Magick::ColorMono::ColorMono
ColorMono(void)
Definition: Color.cpp:739
Magick::Color::_pixel
PixelInfo * _pixel
Definition: Color.h:174
Magick::Color::~Color
virtual ~Color(void)
Definition: Color.cpp:184
Magick::Color::CMYKAPixel
Definition: Color.h:64
Magick::Color::isFuzzyEquivalent
bool isFuzzyEquivalent(const Color &color_, const double fuzz_) const
Definition: Color.cpp:278
Magick::Color::scaleDoubleToQuantum
static Quantum scaleDoubleToQuantum(const double double_)
Definition: Color.cpp:400
Magick::ColorHSL::~ColorHSL
~ColorHSL()
Definition: Color.cpp:618
Magick::Color::isValid
void isValid(const bool valid_)
Definition: Color.cpp:301
Magick::ColorYUV::v
double v(void) const
Definition: Color.cpp:903
Magick::Color::quantumRed
void quantumRed(const Quantum red_)
Definition: Color.cpp:361
Magick::operator>
MagickPPExport int operator>(const Magick::Color &left_, const Magick::Color &right_)
Definition: Color.cpp:44
Magick::ColorYUV::y
double y(void) const
Definition: Color.cpp:914
Magick::operator==
MagickPPExport int operator==(const Magick::Color &left_, const Magick::Color &right_)
Definition: Color.cpp:22
Magick::Image
class MagickPPExport Image
Definition: Drawable.h:722
Magick::Color::operator=
Color & operator=(const Color &color_)
Definition: Color.cpp:192
Magick::ColorRGB::red
double red(void) const
Definition: Color.cpp:851
Magick::ColorMono::operator=
ColorMono & operator=(const Color &color_)
Definition: Color.cpp:759
Magick::ColorGray
Definition: Color.h:246
Magick::ColorGray::~ColorGray
~ColorGray()
Definition: Color.cpp:564
Magick::Color::pixelType
Magick::Color::PixelType pixelType(void) const
Definition: Color.cpp:296
GetPPException
#define GetPPException
Definition: Include.h:1561
Magick::Color::pixel
void pixel(PixelInfo *rep_, PixelType pixelType_)
Definition: Color.cpp:389
Magick::ColorCMYK::alpha
double alpha(void) const
Definition: Color.cpp:498
Exception.h
Magick::ColorCMYK::magenta
double magenta(void) const
Definition: Color.cpp:528
Magick::ColorGray::ColorGray
ColorGray(void)
Definition: Color.cpp:548
Magick::Color::Color
Color(void)
Definition: Color.cpp:78
Magick::ColorHSL::operator=
ColorHSL & operator=(const Color &color_)
Definition: Color.cpp:622