From c7b488da823782a909800a1c0fb6bbd5a80afd3b Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sat, 10 Mar 2018 11:23:18 +0100 Subject: [PATCH] Fixed issue where the an invalid color suddenly becomes valid (#1014). --- Magick++/lib/Color.cpp | 43 +++++++++++++++++++---------------- Magick++/lib/Magick++/Color.h | 4 +++- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/Magick++/lib/Color.cpp b/Magick++/lib/Color.cpp index 4e3bc7f6b..a416d8ea4 100644 --- a/Magick++/lib/Color.cpp +++ b/Magick++/lib/Color.cpp @@ -1,7 +1,7 @@ // This may look like C code, but it is really -*- C++ -*- // // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003 -// Copyright Dirk Lemstra 2013-2015 +// Copyright Dirk Lemstra 2013-2018 // // Color Implementation // @@ -74,7 +74,7 @@ Magick::Color::Color(void) { initPixel(); - quantumAlpha(TransparentAlpha); + setAlpha(TransparentAlpha); } Magick::Color::Color(const Magick::Quantum red_,const Magick::Quantum green_, @@ -309,23 +309,7 @@ void Magick::Color::isValid(bool valid_) void Magick::Color::quantumAlpha(const Magick::Quantum alpha_) { - _pixel->alpha=alpha_; - if (alpha_ == QuantumRange) - { - _pixel->alpha_trait=UndefinedPixelTrait; - if (_pixelType == RGBAPixel) - _pixelType=RGBPixel; - else if (_pixelType == CMYKAPixel) - _pixelType=CMYKPixel; - } - else - { - _pixel->alpha_trait=BlendPixelTrait; - if (_pixelType == RGBPixel) - _pixelType=RGBAPixel; - else if (_pixelType == CMYKPixel) - _pixelType=CMYKAPixel; - } + setAlpha(alpha_); _isValid=true; } @@ -427,6 +411,27 @@ void Magick::Color::initPixel() _pixel->colorspace=CMYKColorspace; } +void Magick::Color::setAlpha(const Magick::Quantum alpha_) +{ + _pixel->alpha=alpha_; + if (alpha_ == QuantumRange) + { + _pixel->alpha_trait=UndefinedPixelTrait; + if (_pixelType == RGBAPixel) + _pixelType=RGBPixel; + else if (_pixelType == CMYKAPixel) + _pixelType=CMYKPixel; + } + else + { + _pixel->alpha_trait=BlendPixelTrait; + if (_pixelType == RGBPixel) + _pixelType=RGBAPixel; + else if (_pixelType == CMYKPixel) + _pixelType=CMYKAPixel; + } +} + void Magick::Color::setPixelType(const PixelInfo &color_) { if (color_.colorspace == CMYKColorspace) diff --git a/Magick++/lib/Magick++/Color.h b/Magick++/lib/Magick++/Color.h index 0b6567b60..d9c73be9e 100644 --- a/Magick++/lib/Magick++/Color.h +++ b/Magick++/lib/Magick++/Color.h @@ -1,7 +1,7 @@ // This may look like C code, but it is really -*- C++ -*- // // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003, 2008 -// Copyright Dirk Lemstra 2013-2014 +// Copyright Dirk Lemstra 2013-2018 // // Color Implementation // @@ -180,6 +180,8 @@ namespace Magick // Common initializer for PixelInfo representation void initPixel(); + void setAlpha(const Magick::Quantum alpha_); + // Sets the pixel type using the specified PixelInfo. void setPixelType(const PixelInfo &color_); }; -- 2.40.0