From: dirk Date: Tue, 4 Nov 2014 21:20:25 +0000 (+0000) Subject: Proper initialization of PixelInfo. X-Git-Tag: 7.0.1-0~1787 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=230403fc83ffb399c0cd889afdc2843a6a3436b9;p=imagemagick Proper initialization of PixelInfo. Fixed string operator. --- diff --git a/Magick++/lib/Color.cpp b/Magick++/lib/Color.cpp index de3aa3fa9..961f9747b 100644 --- a/Magick++/lib/Color.cpp +++ b/Magick++/lib/Color.cpp @@ -81,6 +81,8 @@ Magick::Color::Color(const Quantum red_,const Quantum green_, _pixelOwn(true), _pixelType(RGBPixel) { + initPixel(); + quantumAlpha(OpaqueAlpha); quantumBlack(0); quantumBlue(blue_); @@ -95,6 +97,8 @@ Magick::Color::Color(const Quantum red_,const Quantum green_, _pixelOwn(true), _pixelType(RGBAPixel) { + initPixel(); + quantumAlpha(alpha_); quantumBlack(0); quantumBlue(blue_); @@ -224,10 +228,10 @@ Magick::Color::operator std::string() const if (!isValid()) return std::string("none"); - pixel.colorspace=(_pixelType == RGBAPixel || _pixelType == RGBAPixel) ? + pixel.colorspace=(_pixelType == RGBPixel || _pixelType == RGBAPixel) ? RGBColorspace : CMYKColorspace; - pixel.alpha_trait=_pixelType == RGBAPixel ? BlendPixelTrait : - UndefinedPixelTrait; + pixel.alpha_trait=(_pixelType == RGBAPixel || _pixelType == CMYKAPixel) ? + BlendPixelTrait : UndefinedPixelTrait; pixel.depth=MAGICKCORE_QUANTUM_DEPTH; pixel.alpha=_pixel->alpha; pixel.alpha_trait=_pixel->alpha_trait; @@ -338,6 +342,7 @@ Magick::Color::Color(PixelType pixelType_) _pixelOwn(true), _pixelType(pixelType_) { + initPixel(); } Magick::Color::Color(PixelInfo* rep_,PixelType pixelType_) @@ -375,12 +380,9 @@ double Magick::Color::scaleQuantumToDouble(const Magick::Quantum quantum_) void Magick::Color::initPixel() { - _pixel->alpha=OpaqueAlpha; - _pixel->alpha_trait=UndefinedPixelTrait; - _pixel->black=0; - _pixel->blue=0; - _pixel->green=0; - _pixel->red=0; + MagickCore::GetPixelInfo((MagickCore::Image *) NULL, _pixel); + if (_pixelType == CMYKPixel || _pixelType == CMYKAPixel) + _pixel->colorspace=CMYKColorspace; } void Magick::Color::setPixelType(const PixelInfo &color_)