]> granicus.if.org Git - imagemagick/commitdiff
Fixed issue where the an invalid color suddenly becomes valid (#1014).
authorDirk Lemstra <dirk@git.imagemagick.org>
Sat, 10 Mar 2018 10:23:18 +0000 (11:23 +0100)
committerDirk Lemstra <dirk@git.imagemagick.org>
Sat, 10 Mar 2018 10:23:18 +0000 (11:23 +0100)
Magick++/lib/Color.cpp
Magick++/lib/Magick++/Color.h

index 4e3bc7f6bef873dfcd096869ef2c467bd2167329..a416d8ea47f4e10dcd990f48ee693aba37b47434 100644 (file)
@@ -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)
index 0b6567b60cac23ac61c5c1becba987cfa6f8defd..d9c73be9ea5346324b36f2f397baab218d686ea4 100644 (file)
@@ -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_);
   };