9 #define MAGICKCORE_IMPLEMENTATION 10 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1 23 #if defined(MAGICKCORE_HDRI_SUPPORT) 39 return(!(left_ == right_));
45 return(!(left_ < right_ ) && (left_ != right_ ));
67 return((left_ > right_) || (left_ == right_));
73 return((left_ < right_) || (left_ == right_));
77 : _pixel(new PixelInfo),
84 setAlpha(TransparentAlpha);
89 : _pixel(new PixelInfo),
104 const Magick::Quantum blue_,
const Magick::Quantum alpha_)
105 : _pixel(new PixelInfo),
117 if (alpha_ != OpaqueAlpha)
122 const Magick::Quantum yellow_,
const Magick::Quantum black_,
123 const Magick::Quantum alpha_)
124 : _pixel(new PixelInfo),
127 _pixelType(CMYKPixel)
136 if (alpha_ != OpaqueAlpha)
141 : _pixel(new PixelInfo),
153 : _pixel(new PixelInfo),
154 _isValid(color_._isValid),
156 _pixelType(color_._pixelType)
162 : _pixel(new PixelInfo),
167 setPixelType(color_);
171 : _pixel(new PixelInfo),
187 _pixel=(PixelInfo *)NULL;
199 _isValid=color_._isValid;
202 _pixelType=color_._pixelType;
209 *
this=std::string(color_);
216 setPixelType(color_);
228 if (QueryColorCompliance(color_.c_str(),AllCompliance,&target_color,
231 quantumAlpha(target_color.alpha);
232 quantumBlack(target_color.black);
233 quantumBlue(target_color.blue);
234 quantumGreen(target_color.green);
235 quantumRed(target_color.red);
237 setPixelType(target_color);
246 Magick::Color::operator MagickCore::PixelInfo()
const 251 Magick::Color::operator std::string()
const 254 colorbuf[MagickPathExtent];
260 return std::string(
"none");
262 pixel.colorspace=(_pixelType == RGBPixel || _pixelType == RGBAPixel) ?
263 sRGBColorspace : CMYKColorspace;
264 pixel.alpha_trait=(_pixelType == RGBAPixel || _pixelType == CMYKAPixel) ?
265 BlendPixelTrait : UndefinedPixelTrait;
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);
275 return(std::string(colorbuf));
288 return (IsFuzzyEquivalencePixelInfo(&p, &q) != MagickFalse);
303 if (
bool(valid_) ==
bool(isValid()))
308 _pixel=
new PixelInfo;
325 return(_pixel->alpha);
330 _pixel->black=black_;
336 return(_pixel->black);
347 return(_pixel->blue);
352 _pixel->green=green_;
358 return(_pixel->green);
373 : _pixel(new PixelInfo),
376 _pixelType(pixelType_)
385 _pixelType(pixelType_)
397 _pixelType=pixelType_;
402 return(static_cast<Magick::Quantum>(double_*QuantumRange));
407 #if (MAGICKCORE_QUANTUM_DEPTH < 32) && (MAGICKCORE_SIZEOF_FLOAT_T != MAGICKCORE_SIZEOF_DOUBLE || !defined(MAGICKCORE_HDRI_SUPPORT)) 408 return(static_cast<double>(QuantumScale*quantum_));
410 return(QuantumScale*quantum_);
414 void Magick::Color::initPixel()
417 if (_pixelType == CMYKPixel || _pixelType == CMYKAPixel)
418 _pixel->colorspace=CMYKColorspace;
421 void Magick::Color::setAlpha(
const Magick::Quantum alpha_)
423 _pixel->alpha=alpha_;
424 if (alpha_ == OpaqueAlpha)
426 _pixel->alpha_trait=UndefinedPixelTrait;
427 if (_pixelType == RGBAPixel)
429 else if (_pixelType == CMYKAPixel)
430 _pixelType=CMYKPixel;
434 _pixel->alpha_trait=BlendPixelTrait;
435 if (_pixelType == RGBPixel)
436 _pixelType=RGBAPixel;
437 else if (_pixelType == CMYKPixel)
438 _pixelType=CMYKAPixel;
442 void Magick::Color::setPixelType(
const PixelInfo &color_)
444 if (color_.colorspace == CMYKColorspace)
445 _pixelType=color_.alpha_trait != UndefinedPixelTrait ? CMYKAPixel :
448 _pixelType=color_.alpha_trait != UndefinedPixelTrait ? RGBAPixel :
463 const double yellow_,
const double black_)
473 const double yellow_,
const double black_,
const double alpha_)
495 quantumAlpha(scaleDoubleToQuantum(alpha_));
500 return(scaleQuantumToDouble(quantumAlpha()));
505 quantumBlack(scaleDoubleToQuantum(black_));
510 return(scaleQuantumToDouble(quantumBlack()));
515 quantumRed(scaleDoubleToQuantum(cyan_));
520 return(scaleQuantumToDouble(quantumRed()));
525 quantumGreen(scaleDoubleToQuantum(magenta_));
530 return(scaleQuantumToDouble(quantumGreen()));
535 quantumBlue(scaleDoubleToQuantum(yellow_));
540 return(scaleQuantumToDouble(quantumBlue()));
544 :
Color(rep_,pixelType_)
559 :
Color(scaleDoubleToQuantum(shade_),scaleDoubleToQuantum(shade_),
560 scaleDoubleToQuantum(shade_))
570 Quantum gray=scaleDoubleToQuantum(shade_);
578 return(scaleQuantumToDouble(quantumGreen()));
588 :
Color(rep_,pixelType_)
603 const double lightness_)
611 ConvertHSLToRGB(hue_,saturation_,lightness_,&red,&green,&blue);
640 ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
645 ConvertHSLToRGB(hue,saturation,lightness,&red,&green,&blue);
647 quantumRed(ClampToQuantum(red));
648 quantumGreen(ClampToQuantum(green));
649 quantumBlue(ClampToQuantum(blue));
659 ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
677 ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
680 lightness=lightness_;
682 ConvertHSLToRGB(hue,saturation,lightness,&red,&green,&blue);
684 quantumRed(ClampToQuantum(red));
685 quantumGreen(ClampToQuantum(green));
686 quantumBlue(ClampToQuantum(blue));
696 ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
714 ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
717 saturation=saturation_;
719 ConvertHSLToRGB(hue,saturation,lightness,&red,&green,&blue);
721 quantumRed(ClampToQuantum(red));
722 quantumGreen(ClampToQuantum(green));
723 quantumBlue(ClampToQuantum(blue));
733 ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
745 :
Color((mono_ ? QuantumRange : 0),(mono_ ? QuantumRange : 0),
746 (mono_ ? QuantumRange : 0))
767 quantumRed(mono_ ? QuantumRange : 0);
768 quantumGreen(mono_ ? QuantumRange : 0);
769 quantumBlue(mono_ ? QuantumRange : 0);
774 return(quantumGreen() == 0);
778 :
Color(rep_,pixelType_)
794 :
Color(scaleDoubleToQuantum(red_),scaleDoubleToQuantum(green_),
795 scaleDoubleToQuantum(blue_))
800 const double blue_,
const double alpha_)
801 :
Color(scaleDoubleToQuantum(red_),scaleDoubleToQuantum(green_),
802 scaleDoubleToQuantum(blue_),scaleDoubleToQuantum(alpha_))
818 quantumAlpha(scaleDoubleToQuantum(alpha_));
823 return(scaleQuantumToDouble(quantumAlpha()));
828 quantumBlue(scaleDoubleToQuantum(blue_));
833 return(scaleQuantumToDouble(quantumBlue()));
838 quantumGreen(scaleDoubleToQuantum(green_));
843 return(scaleQuantumToDouble(quantumGreen()));
848 quantumRed(scaleDoubleToQuantum(red_));
853 return(scaleQuantumToDouble(quantumRed()));
857 :
Color(rep_,pixelType_)
889 convert(y(), u_, v());
894 return(scaleQuantumToDouble((-0.14740 * quantumRed()) - (0.28950 *
895 quantumGreen()) + (0.43690 * quantumBlue())));
900 convert(y(), u(), v_);
905 return(scaleQuantumToDouble((0.61500 * quantumRed()) - (0.51500 *
906 quantumGreen()) - (0.10000 * quantumBlue())));
911 convert(y_, u(), v());
916 return(scaleQuantumToDouble((0.29900 * quantumRed()) + (0.58700 *
917 quantumGreen()) + (0.11400 * quantumBlue())));
920 void Magick::ColorYUV::convert(
const double y_,
const double u_,
const double v_)
922 quantumRed(scaleDoubleToQuantum(y_ + 1.13980 * v_));
923 quantumGreen(scaleDoubleToQuantum(y_ - (0.39380 * u_) - (0.58050 * v_)));
924 quantumBlue(scaleDoubleToQuantum(y_ + 2.02790 * u_));
928 :
Color(rep_,pixelType_)
ColorYUV & operator=(const Color &color_)
MagickPPExport int operator!=(const Magick::Color &left_, const Magick::Color &right_)
void quantumGreen(const Quantum green_)
Quantum quantumGreen(void) const
Quantum quantumAlpha(void) const
double lightness(void) const
Quantum quantumBlue(void) const
void quantumBlue(const Quantum blue_)
MagickPPExport int operator<(const Magick::Color &left_, const Magick::Color &right_)
ColorGray & operator=(const Color &color_)
MagickPPExport int operator<=(const Magick::Color &left_, const Magick::Color &right_)
MagickPPExport int operator>=(const Magick::Color &left_, const Magick::Color &right_)
Quantum quantumRed(void) const
ColorCMYK & operator=(const Color &color_)
ColorRGB & operator=(const Color &color_)
Quantum quantumBlack(void) const
double saturation(void) const
#define ThrowPPException(quiet)
static double scaleQuantumToDouble(const Quantum quantum_)
double yellow(void) const
bool isFuzzyEquivalent(const Color &color_, const double fuzz_) const
static Quantum scaleDoubleToQuantum(const double double_)
void isValid(const bool valid_)
void quantumRed(const Quantum red_)
MagickPPExport int operator>(const Magick::Color &left_, const Magick::Color &right_)
MagickPPExport int operator==(const Magick::Color &left_, const Magick::Color &right_)
class MagickPPExport Image
Color & operator=(const Color &color_)
ColorMono & operator=(const Color &color_)
Magick::Color::PixelType pixelType(void) const
void pixel(PixelInfo *rep_, PixelType pixelType_)
double magenta(void) const
ColorHSL & operator=(const Color &color_)