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