Whitespace cleanup.
Renamed ColorRGB to ColorRGBA.
Some refactoring in Color class.
diff --git a/Magick++/lib/Blob.cpp b/Magick++/lib/Blob.cpp
index 83e9518..e890094 100644
--- a/Magick++/lib/Blob.cpp
+++ b/Magick++/lib/Blob.cpp
@@ -14,10 +14,6 @@
#include <string.h>
-//
-// Implementation of Magick::Blob
-//
-
Magick::Blob::Blob(void)
: _blobRef(new Magick::BlobRef(0,0))
{
@@ -79,10 +75,9 @@
}
_blobRef=blob_._blobRef;
}
- return *this;
+ return(*this);
}
-// Update object contents from Base64-encoded string representation.
void Magick::Blob::base64(const std::string base64_)
{
size_t
@@ -98,8 +93,7 @@
Magick::Blob::MallocAllocator);
}
-// Return Base64-encoded string representation.
-std::string Magick::Blob::base64(void)
+std::string Magick::Blob::base64(void) const
{
size_t
encoded_length;
@@ -121,7 +115,17 @@
return result;
}
- return std::string();
+ return(std::string());
+}
+
+const void* Magick::Blob::data(void) const
+{
+ return(_blobRef->data);
+}
+
+size_t Magick::Blob::length(void) const
+{
+ return(_blobRef->length);
}
void Magick::Blob::update(const void* data_,size_t length_)
@@ -167,13 +171,3 @@
_blobRef->allocator=allocator_;
}
-const void* Magick::Blob::data(void) const
-{
- return _blobRef->data;
-}
-
-size_t Magick::Blob::length(void) const
-{
- return _blobRef->length;
-}
-
diff --git a/Magick++/lib/BlobRef.cpp b/Magick++/lib/BlobRef.cpp
index 2236dd3..58bc184 100644
--- a/Magick++/lib/BlobRef.cpp
+++ b/Magick++/lib/BlobRef.cpp
@@ -14,10 +14,6 @@
#include <string.h>
-//
-// Implementation of Magick::BlobRef
-//
-
Magick::BlobRef::BlobRef(const void* data_,size_t length_)
: data(0),
length(length_),
diff --git a/Magick++/lib/CoderInfo.cpp b/Magick++/lib/CoderInfo.cpp
index 3c146af..05d65d7 100644
--- a/Magick++/lib/CoderInfo.cpp
+++ b/Magick++/lib/CoderInfo.cpp
@@ -71,36 +71,6 @@
{
}
-std::string Magick::CoderInfo::description(void) const
-{
- return _description;
-}
-
-bool Magick::CoderInfo::isReadable(void) const
-{
- return _isReadable;
-}
-
-bool Magick::CoderInfo::isWritable(void) const
-{
- return _isWritable;
-}
-
-bool Magick::CoderInfo::isMultiFrame(void) const
-{
- return _isMultiFrame;
-}
-
-std::string Magick::CoderInfo::mimeType(void) const
-{
- return _mimeType;
-}
-
-std::string Magick::CoderInfo::name(void) const
-{
- return _name;
-}
-
Magick::CoderInfo& Magick::CoderInfo::operator=(const CoderInfo &coder_)
{
// If not being set to ourself
@@ -113,15 +83,35 @@
_isWritable=coder_._isWritable;
_isMultiFrame=coder_._isMultiFrame;
}
- return *this;
+ return(*this);
}
-Magick::CoderInfo::CoderInfo(const MagickCore::MagickInfo *magickInfo_)
- : _name(string(magickInfo_->name ? magickInfo_->name : "")),
- _description(string(magickInfo_->description ? magickInfo_->description : "")),
- _mimeType(string(magickInfo_->mime_type ? magickInfo_->mime_type : "")),
- _isReadable(magickInfo_->decoder ? true : false),
- _isWritable(magickInfo_->encoder ? true : false),
- _isMultiFrame(magickInfo_->adjoin ? true : false)
+std::string Magick::CoderInfo::description(void) const
{
+ return(_description);
+}
+
+bool Magick::CoderInfo::isReadable(void) const
+{
+ return(_isReadable);
+}
+
+bool Magick::CoderInfo::isWritable(void) const
+{
+ return(_isWritable);
+}
+
+bool Magick::CoderInfo::isMultiFrame(void) const
+{
+ return(_isMultiFrame);
+}
+
+std::string Magick::CoderInfo::mimeType(void) const
+{
+ return(_mimeType);
+}
+
+std::string Magick::CoderInfo::name(void) const
+{
+ return(_name);
}
diff --git a/Magick++/lib/Color.cpp b/Magick++/lib/Color.cpp
index 7905088..deed4cc 100644
--- a/Magick++/lib/Color.cpp
+++ b/Magick++/lib/Color.cpp
@@ -16,197 +16,164 @@
#include "Magick++/Color.h"
#include "Magick++/Exception.h"
-//
-// Color operator fuctions
-//
-int Magick::operator == ( const Magick::Color& left_,
- const Magick::Color& right_ )
+int Magick::operator == (const Magick::Color &left_,
+ const Magick::Color &right_)
{
- return ( ( left_.isValid() == right_.isValid() ) &&
- ( left_.redQuantum() == right_.redQuantum() ) &&
- ( left_.greenQuantum() == right_.greenQuantum() ) &&
- ( left_.blueQuantum() == right_.blueQuantum() )
- );
-}
-int Magick::operator != ( const Magick::Color& left_,
- const Magick::Color& right_ )
-{
- return ( ! (left_ == right_) );
-}
-int Magick::operator > ( const Magick::Color& left_,
- const Magick::Color& right_ )
-{
- return ( !( left_ < right_ ) && ( left_ != right_ ) );
-}
-int Magick::operator < ( const Magick::Color& left_,
- const Magick::Color& right_ )
-{
- if(left_.redQuantum() < right_.redQuantum()) return true;
- if(left_.redQuantum() > right_.redQuantum()) return false;
- if(left_.greenQuantum() < right_.greenQuantum()) return true;
- if(left_.greenQuantum() > right_.greenQuantum()) return false;
- if(left_.blueQuantum() < right_.blueQuantum()) return true;
- return false;
-}
-int Magick::operator >= ( const Magick::Color& left_,
- const Magick::Color& right_ )
-{
- return ( ( left_ > right_ ) || ( left_ == right_ ) );
-}
-int Magick::operator <= ( const Magick::Color& left_,
- const Magick::Color& right_ )
-{
- return ( ( left_ < right_ ) || ( left_ == right_ ) );
+ return((left_.isValid() == right_.isValid()) &&
+ (left_.quantumRed() == right_.quantumRed()) &&
+ (left_.quantumGreen() == right_.quantumGreen()) &&
+ (left_.quantumBlue() == right_.quantumBlue()));
}
-//
-// Color Implementation
-//
+int Magick::operator != (const Magick::Color &left_,
+ const Magick::Color &right_)
+{
+ return(!(left_ == right_));
+}
-// Default constructor
-Magick::Color::Color ( void )
- : _pixel(new PixelInfo),
- _pixelOwn(true),
- _isValid(false),
- _pixelType(RGBPixel)
+int Magick::operator > (const Magick::Color &left_,
+ const Magick::Color &right_)
+{
+ return(!(left_ < right_ ) && (left_ != right_ ));
+}
+
+int Magick::operator < ( const Magick::Color &left_,
+ const Magick::Color &right_)
+{
+ if(left_.quantumRed() < right_.quantumRed())
+ return(true);
+ if(left_.quantumRed() > right_.quantumRed())
+ return(false);
+ if(left_.quantumGreen() < right_.quantumGreen())
+ return(true);
+ if(left_.quantumGreen() > right_.quantumGreen())
+ return(false);
+ if(left_.quantumBlue() < right_.quantumBlue())
+ return(true);
+ return(false);
+}
+
+int Magick::operator >= (const Magick::Color &left_,
+ const Magick::Color &right_)
+{
+ return((left_ > right_) || (left_ == right_));
+}
+
+int Magick::operator <= ( const Magick::Color &left_,
+ const Magick::Color &right_)
+{
+ return((left_ < right_) || (left_ == right_));
+}
+
+Magick::Color::Color(void)
+ : _pixel(new PixelInfo),_pixelOwn(true),_isValid(false),_pixelType(RGBPixel)
{
initPixel();
}
-// Construct from RGB
-Magick::Color::Color ( Quantum red_,
- Quantum green_,
- Quantum blue_ )
- : _pixel(new PixelInfo),
- _pixelOwn(true),
- _isValid(true),
- _pixelType(RGBPixel)
+Magick::Color::Color(const Quantum red_,const Quantum green_,
+ const Quantum blue_)
+ : _pixel(new PixelInfo),_pixelOwn(true),_isValid(true),_pixelType(RGBPixel)
{
- redQuantum ( red_ );
- greenQuantum ( green_ );
- blueQuantum ( blue_ );
- alphaQuantum ( OpaqueAlpha );
+ quantumRed(red_);
+ quantumGreen(green_);
+ quantumBlue(blue_);
+ quantumAlpha(OpaqueAlpha);
}
-// Construct from RGBA
-Magick::Color::Color ( Quantum red_,
- Quantum green_,
- Quantum blue_,
- Quantum alpha_ )
- : _pixel(new PixelInfo),
- _pixelOwn(true),
- _isValid(true),
- _pixelType(RGBAPixel)
+Magick::Color::Color(const Quantum red_,const Quantum green_,
+ const Quantum blue_, const Quantum alpha_)
+ : _pixel(new PixelInfo),_pixelOwn(true),_isValid(true),_pixelType(RGBAPixel)
{
- redQuantum ( red_ );
- greenQuantum ( green_ );
- blueQuantum ( blue_ );
- alphaQuantum ( alpha_ );
+ quantumRed(red_);
+ quantumGreen(green_);
+ quantumBlue(blue_);
+ quantumAlpha(alpha_);
}
-// Copy constructor
-Magick::Color::Color ( const Magick::Color & color_ )
- : _pixel( new PixelInfo ),
- _pixelOwn( true ),
- _isValid( color_._isValid ),
- _pixelType( color_._pixelType )
+Magick::Color::Color(const Magick::Color & color_)
+ : _pixel(new PixelInfo),_pixelOwn(true),_isValid(color_._isValid),
+ _pixelType(color_._pixelType)
{
- *_pixel = *color_._pixel;
+ *_pixel=*color_._pixel;
}
-// Construct from color expressed as C++ string
-Magick::Color::Color ( const std::string &x11color_ )
- : _pixel(new PixelInfo),
- _pixelOwn(true),
- _isValid(true),
- _pixelType(RGBPixel)
+Magick::Color::Color(const PixelInfo &color_)
+ : _pixel(new PixelInfo),_pixelOwn(true),_isValid(true),_pixelType(RGBPixel)
+{
+ *_pixel=color_;
+
+ if (color_.alpha != OpaqueAlpha)
+ _pixelType=RGBAPixel;
+}
+
+Magick::Color::Color(const std::string &color_)
+ : _pixel(new PixelInfo),_pixelOwn(true),_isValid(true),_pixelType(RGBPixel)
{
initPixel();
// Use operator = implementation
- *this = x11color_;
+ *this=color_;
}
-// Construct from color expressed as C string
-Magick::Color::Color ( const char * x11color_ )
- : _pixel(new PixelInfo),
- _pixelOwn(true),
- _isValid(true),
- _pixelType(RGBPixel)
+Magick::Color::~Color(void)
{
- initPixel();
-
- // Use operator = implementation
- *this = x11color_;
-}
-
-// Construct color via ImageMagick PixelInfo
-Magick::Color::Color ( const PixelInfo &color_ )
- : _pixel(new PixelInfo),
- _pixelOwn(true), // We allocated this pixel
- _isValid(true),
- _pixelType(RGBPixel) // RGB pixel by default
-{
- *_pixel = color_;
-
- if ( color_.alpha != OpaqueAlpha )
- _pixelType = RGBAPixel;
-}
-
-// Protected constructor to construct with PixelInfo*
-// Used to point Color at a pixel.
-Magick::Color::Color ( PixelInfo* rep_, PixelType pixelType_ )
- : _pixel(rep_),
- _pixelOwn(false),
- _isValid(true),
- _pixelType(pixelType_)
-{
-}
-
-// Destructor
-Magick::Color::~Color( void )
-{
- if ( _pixelOwn )
+ if (_pixelOwn)
delete _pixel;
- _pixel=0;
+
+ _pixel=(PixelInfo *)NULL;
}
-// Assignment operator
-Magick::Color& Magick::Color::operator = ( const Magick::Color& color_ )
+Magick::Color& Magick::Color::operator=(const Magick::Color& color_)
{
// If not being set to ourself
- if ( this != &color_ )
+ if (this != &color_)
{
// Copy pixel value
- *_pixel = *color_._pixel;
+ *_pixel=*color_._pixel;
// Validity
- _isValid = color_._isValid;
+ _isValid=color_._isValid;
// Copy pixel type
- _pixelType = color_._pixelType;
+ _pixelType=color_._pixelType;
}
- return *this;
+ return(*this);
}
-// Set color via X11 color specification string
-const Magick::Color& Magick::Color::operator = ( const std::string &x11color_ )
+const Magick::Color& Magick::Color::operator=(const MagickCore::PixelInfo &color_)
{
- initPixel();
- PixelInfo target_color;
- ExceptionInfo exception;
- GetExceptionInfo( &exception );
- if ( QueryColorCompliance( x11color_.c_str(), AllCompliance, &target_color, &exception ) )
- {
- redQuantum( ClampToQuantum( target_color.red ) );
- greenQuantum( ClampToQuantum( target_color.green ) );
- blueQuantum( ClampToQuantum( target_color.blue ) );
- alphaQuantum( ClampToQuantum( target_color.alpha ) );
+ *_pixel=color_;
+ if (color_.alpha != OpaqueAlpha)
+ _pixelType=RGBAPixel;
+ else
+ _pixelType=RGBPixel;
- if ( target_color.alpha != OpaqueAlpha )
- _pixelType = RGBAPixel;
+ return(*this);
+}
+
+const Magick::Color& Magick::Color::operator=(const std::string &color_)
+{
+ ExceptionInfo
+ exception;
+
+ PixelInfo
+ target_color;
+
+ initPixel();
+ GetExceptionInfo(&exception);
+ if (QueryColorCompliance(color_.c_str(),AllCompliance,&target_color,
+ &exception))
+ {
+ quantumRed(target_color.red);
+ quantumGreen(target_color.green);
+ quantumBlue(target_color.blue);
+ quantumAlpha(target_color.alpha);
+
+ if (quantumAlpha() != OpaqueAlpha)
+ _pixelType=RGBAPixel;
else
- _pixelType = RGBPixel;
+ _pixelType=RGBPixel;
}
else
{
@@ -215,27 +182,25 @@
}
(void) DestroyExceptionInfo( &exception );
- return *this;
+ return(*this);
}
-// Set color via X11 color specification C string
-const Magick::Color& Magick::Color::operator = ( const char * x11color_ )
+inline Magick::Color::operator MagickCore::PixelInfo() const
{
- *this = std::string(x11color_);
- return *this;
+ return *_pixel;
}
-// Return X11 color specification string
Magick::Color::operator std::string() const
{
- if ( !isValid() )
- return std::string("none");
-
- char colorbuf[MaxTextExtent];
+ char
+ colorbuf[MaxTextExtent];
PixelInfo
pixel;
+ if (!isValid())
+ return std::string("none");
+
pixel.colorspace=RGBColorspace;
pixel.alpha_trait=_pixelType == RGBAPixel ? BlendPixelTrait :
UndefinedPixelTrait;
@@ -244,48 +209,55 @@
pixel.green=_pixel->green;
pixel.blue=_pixel->blue;
pixel.alpha=_pixel->alpha;
- GetColorTuple( &pixel, MagickTrue, colorbuf );
+ GetColorTuple(&pixel,MagickTrue,colorbuf);
- return std::string(colorbuf);
+ return(std::string(colorbuf));
}
-// Set color via ImageMagick PixelInfo
-const Magick::Color& Magick::Color::operator= ( const MagickCore::PixelInfo &color_ )
+void Magick::Color::alpha(const double alpha_)
{
- *_pixel = color_;
- if ( color_.alpha != OpaqueAlpha )
- _pixelType = RGBAPixel;
- else
- _pixelType = RGBPixel;
- return *this;
+ quantumAlpha(scaleDoubleToQuantum(alpha_));
}
-// Set pixel
-// Used to point Color at a pixel in an image
-void Magick::Color::pixel ( PixelInfo* rep_, PixelType pixelType_ )
+double Magick::Color::alpha(void) const
{
- if ( _pixelOwn )
- delete _pixel;
- _pixel = rep_;
- _pixelOwn = false;
- _isValid = true;
- _pixelType = pixelType_;
+ return scaleQuantumToDouble(quantumAlpha());
}
-// Does object contain valid color?
-bool Magick::Color::isValid ( void ) const
+void Magick::Color::blue(const double blue_)
{
- return( _isValid );
+ quantumBlue(scaleDoubleToQuantum(blue_));
}
-void Magick::Color::isValid ( bool valid_ )
+
+double Magick::Color::blue(void) const
{
- if ( (valid_ && isValid()) || (!valid_ && !isValid()) )
+ return scaleQuantumToDouble(quantumBlue());
+}
+
+void Magick::Color::green(const double green_)
+{
+ quantumGreen(scaleDoubleToQuantum(green_));
+}
+
+double Magick::Color::green(void) const
+{
+ return scaleQuantumToDouble(quantumGreen());
+}
+
+bool Magick::Color::isValid(void) const
+{
+ return(_isValid);
+}
+
+void Magick::Color::isValid(bool valid_)
+{
+ if ((valid_ && isValid()) || (!valid_ && !isValid()))
return;
- if ( !_pixelOwn )
+ if (!_pixelOwn)
{
- _pixel = new PixelInfo;
- _pixelOwn = true;
+ _pixel=new PixelInfo;
+ _pixelOwn=true;
}
_isValid=valid_;
@@ -293,404 +265,438 @@
initPixel();
}
-//
-// ColorHSL Implementation
-//
-
-Magick::ColorHSL::ColorHSL ( double hue_,
- double saturation_,
- double luminosity_ )
- : Color ()
+void Magick::Color::quantumAlpha(const Magick::Quantum alpha_)
{
- double red, green, blue;
-
- ConvertHSLToRGB ( hue_,
- saturation_,
- luminosity_,
- &red,
- &green,
- &blue );
-
- redQuantum ( ClampToQuantum( red ) );
- greenQuantum ( ClampToQuantum( green ) );
- blueQuantum ( ClampToQuantum( blue ) );
- alphaQuantum ( OpaqueAlpha );
+ _pixel->alpha=alpha_;
+ _isValid=true ;
}
-// Null constructor
-Magick::ColorHSL::ColorHSL ( )
- : Color ()
+Magick::Quantum Magick::Color::quantumAlpha(void) const
+{
+ return _pixel->alpha;
+}
+
+void Magick::Color::quantumBlue(const Magick::Quantum blue_)
+{
+ _pixel->blue=blue_;
+ _isValid=true;
+}
+
+Magick::Quantum Magick::Color::quantumBlue(void) const
+{
+ return _pixel->blue;
+}
+
+void Magick::Color::quantumGreen(const Magick::Quantum green_)
+{
+ _pixel->green=green_;
+ _isValid=true;
+}
+
+Magick::Quantum Magick::Color::quantumGreen(void) const
+{
+ return _pixel->green;
+}
+
+void Magick::Color::quantumRed(const Magick::Quantum red_)
+{
+ _pixel->red=red_;
+ _isValid=true;
+}
+
+inline Magick::Quantum Magick::Color::quantumRed(void) const
+{
+ return _pixel->red;
+}
+
+void Magick::Color::red(const double red_)
+{
+ quantumRed(scaleDoubleToQuantum(red_));
+}
+
+double Magick::Color::red(void) const
+{
+ return scaleQuantumToDouble(quantumRed());
+}
+
+Magick::Color::Color(PixelInfo* rep_,PixelType pixelType_)
+ : _pixel(rep_),_pixelOwn(false),_isValid(true),_pixelType(pixelType_)
{
}
-// Copy constructor from base class
-Magick::ColorHSL::ColorHSL ( const Magick::Color & color_ )
- : Color( color_ )
+void Magick::Color::pixel(PixelInfo *rep_,PixelType pixelType_)
+{
+ if (_pixelOwn)
+ delete _pixel;
+
+ _pixel=rep_;
+ _pixelOwn=false;
+ _isValid=true;
+ _pixelType=pixelType_;
+}
+
+Magick::Quantum Magick::Color::scaleDoubleToQuantum(const double double_)
+{
+ return (static_cast<Magick::Quantum>(double_*QuantumRange));
+}
+
+double Magick::Color::scaleQuantumToDouble(const Magick::Quantum quantum_)
+{
+#if (MAGICKCORE_QUANTUM_DEPTH != 64)
+ return (static_cast<double>(quantum_)/QuantumRange);
+#else
+ return (quantum_/QuantumRange);
+#endif
+}
+
+void Magick::Color::initPixel()
+{
+ _pixel->red=0;
+ _pixel->green=0;
+ _pixel->blue=0;
+ _pixel->alpha=TransparentAlpha;
+}
+
+Magick::ColorGray::ColorGray(void)
+ : Color()
{
}
-// Destructor
-Magick::ColorHSL::~ColorHSL ( )
+Magick::ColorGray::ColorGray(const Magick::Color & color_)
+ : Color(color_)
{
- // Nothing to do
}
-void Magick::ColorHSL::hue ( double hue_ )
+Magick::ColorGray::ColorGray(double shade_)
+ : Color(scaleDoubleToQuantum(shade_),scaleDoubleToQuantum(shade_),
+ scaleDoubleToQuantum(shade_))
{
- double hue_val, saturation_val, luminosity_val;
- ConvertRGBToHSL ( redQuantum(),
- greenQuantum(),
- blueQuantum(),
- &hue_val,
- &saturation_val,
- &luminosity_val );
-
- hue_val = hue_;
-
- double red, green, blue;
- ConvertHSLToRGB ( hue_val,
- saturation_val,
- luminosity_val,
- &red,
- &green,
- &blue
- );
-
- redQuantum ( ClampToQuantum( red ) );
- greenQuantum ( ClampToQuantum( green ) );
- blueQuantum ( ClampToQuantum( blue ) );
+ quantumAlpha(OpaqueAlpha);
}
-double Magick::ColorHSL::hue ( void ) const
+Magick::ColorGray::~ColorGray()
{
- double hue_val, saturation_val, luminosity_val;
- ConvertRGBToHSL ( redQuantum(),
- greenQuantum(),
- blueQuantum(),
- &hue_val,
- &saturation_val,
- &luminosity_val );
- return hue_val;
}
-void Magick::ColorHSL::saturation ( double saturation_ )
+void Magick::ColorGray::shade(double shade_)
{
- double hue_val, saturation_val, luminosity_val;
- ConvertRGBToHSL ( redQuantum(),
- greenQuantum(),
- blueQuantum(),
- &hue_val,
- &saturation_val,
- &luminosity_val );
-
- saturation_val = saturation_;
-
- double red, green, blue;
- ConvertHSLToRGB ( hue_val,
- saturation_val,
- luminosity_val,
- &red,
- &green,
- &blue
- );
-
- redQuantum ( ClampToQuantum( red ) );
- greenQuantum ( ClampToQuantum( green ) );
- blueQuantum ( ClampToQuantum( blue ) );
+ red(shade_);
+ green(shade_);
+ blue(shade_);
}
-double Magick::ColorHSL::saturation ( void ) const
+double Magick::ColorGray::shade(void) const
{
- double hue_val, saturation_val, luminosity_val;
- ConvertRGBToHSL ( redQuantum(),
- greenQuantum(),
- blueQuantum(),
- &hue_val,
- &saturation_val,
- &luminosity_val );
- return saturation_val;
+ return(green());
}
-void Magick::ColorHSL::luminosity ( double luminosity_ )
+Magick::ColorGray& Magick::ColorGray::operator=(const Magick::Color& color_)
{
- double hue_val, saturation_val, luminosity_val;
- ConvertRGBToHSL ( redQuantum(),
- greenQuantum(),
- blueQuantum(),
- &hue_val,
- &saturation_val,
- &luminosity_val );
-
- luminosity_val = luminosity_;
-
- double red, green, blue;
- ConvertHSLToRGB ( hue_val,
- saturation_val,
- luminosity_val,
- &red,
- &green,
- &blue
- );
-
- redQuantum ( ClampToQuantum( red ) );
- greenQuantum ( ClampToQuantum( green ) );
- blueQuantum ( ClampToQuantum( blue ) );
+ *static_cast<Magick::Color*>(this)=color_;
+ return(*this);
+}
+
+Magick::ColorGray::ColorGray(PixelInfo *rep_,PixelType pixelType_)
+: Color(rep_,pixelType_)
+{
+}
+
+Magick::ColorHSL::ColorHSL(void)
+ : Color()
+{
+}
+
+Magick::ColorHSL::ColorHSL(const Magick::Color &color_)
+ : Color(color_)
+{
+}
+
+Magick::ColorHSL::ColorHSL(const double hue_,const double saturation_,
+ const double luminosity_)
+ : Color()
+{
+ double
+ blue,
+ green,
+ red;
+
+ ConvertHSLToRGB(hue_,saturation_,luminosity_,&red,&green,&blue);
+
+ quantumRed(red);
+ quantumGreen(green);
+ quantumBlue(blue);
+ quantumAlpha(OpaqueAlpha);
+}
+
+Magick::ColorHSL::~ColorHSL()
+{
+}
+
+Magick::ColorHSL& Magick::ColorHSL::operator=(const Magick::Color& color_)
+{
+ *static_cast<Magick::Color*>(this) = color_;
+ return(*this);
+}
+
+void Magick::ColorHSL::hue(const double hue_)
+{
+ double
+ hue,
+ luminosity,
+ saturation;
+
+ double
+ blue,
+ green,
+ red;
+
+ ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
+ &luminosity);
+
+ hue=hue_;
+
+ ConvertHSLToRGB(hue,saturation,luminosity,&red,&green,&blue);
+
+ quantumRed(red);
+ quantumGreen(green);
+ quantumBlue(blue);
+}
+
+double Magick::ColorHSL::hue(void) const
+{
+ double
+ hue,
+ luminosity,
+ saturation;
+
+ ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
+ &luminosity);
+
+ return(hue);
+}
+
+void Magick::ColorHSL::luminosity(const double luminosity_)
+{
+ double
+ hue,
+ luminosity,
+ saturation;
+
+ double
+ blue,
+ green,
+ red;
+
+ ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
+ &luminosity);
+
+ luminosity=luminosity_;
+
+ ConvertHSLToRGB(hue,saturation,luminosity,&red,&green,&blue);
+
+ quantumRed(red);
+ quantumGreen(green);
+ quantumBlue(blue);
}
double Magick::ColorHSL::luminosity ( void ) const
{
- double hue_val, saturation_val, luminosity_val;
- ConvertRGBToHSL ( redQuantum(),
- greenQuantum(),
- blueQuantum(),
- &hue_val,
- &saturation_val,
- &luminosity_val );
- return luminosity_val;
+ double
+ hue,
+ luminosity,
+ saturation;
+
+ ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
+ &luminosity);
+
+ return(luminosity);
}
-// Assignment from base class
-Magick::ColorHSL& Magick::ColorHSL::operator = ( const Magick::Color& color_ )
+void Magick::ColorHSL::saturation(const double saturation_)
{
- *static_cast<Magick::Color*>(this) = color_;
- return *this;
+ double
+ hue,
+ luminosity,
+ saturation;
+
+ double
+ blue,
+ green,
+ red;
+
+ ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
+ &luminosity);
+
+ saturation=saturation_;
+
+ ConvertHSLToRGB(hue,saturation,luminosity,&red,&green,&blue);
+
+ quantumRed(red);
+ quantumGreen(green);
+ quantumBlue(blue);
}
-//
-// ColorGray Implementation
-//
-Magick::ColorGray::ColorGray ( double shade_ )
- : Color ( scaleDoubleToQuantum( shade_ ),
- scaleDoubleToQuantum( shade_ ),
- scaleDoubleToQuantum( shade_ ) )
+double Magick::ColorHSL::saturation(void) const
{
- alphaQuantum ( OpaqueAlpha );
+ double
+ hue,
+ luminosity,
+ saturation;
+
+ ConvertRGBToHSL(quantumRed(),quantumGreen(),quantumBlue(),&hue,&saturation,
+ &luminosity);
+
+ return(saturation);
}
-// Null constructor
-Magick::ColorGray::ColorGray ( void )
- : Color ()
+Magick::ColorMono::ColorMono(void)
+ : Color()
{
}
-// Copy constructor from base class
-Magick::ColorGray::ColorGray ( const Magick::Color & color_ )
- : Color( color_ )
+Magick::ColorMono::ColorMono(const bool mono_)
+ : Color((Quantum)(mono_ ? QuantumRange : 0),
+ (Quantum)(mono_ ? QuantumRange : 0),
+ (Quantum)(mono_ ? QuantumRange : 0))
+{
+ quantumAlpha(OpaqueAlpha);
+}
+
+Magick::ColorMono::ColorMono(const Magick::Color &color_)
+ : Color(color_)
{
}
-// Destructor
-Magick::ColorGray::~ColorGray ()
-{
- // Nothing to do
-}
-
-void Magick::ColorGray::shade ( double shade_ )
-{
- Quantum gray = scaleDoubleToQuantum( shade_ );
- redQuantum ( gray );
- greenQuantum ( gray );
- blueQuantum ( gray );
-}
-
-double Magick::ColorGray::shade ( void ) const
-{
- return scaleQuantumToDouble ( greenQuantum() );
-}
-
-// Assignment from base class
-Magick::ColorGray& Magick::ColorGray::operator = ( const Magick::Color& color_ )
-{
- *static_cast<Magick::Color*>(this) = color_;
- return *this;
-}
-
-//
-// ColorMono Implementation
-//
-Magick::ColorMono::ColorMono ( bool mono_ )
- : Color ( ( mono_ ? QuantumRange : 0 ),
- ( mono_ ? QuantumRange : 0 ),
- ( mono_ ? QuantumRange : 0 ) )
-{
- alphaQuantum ( OpaqueAlpha );
-}
-
-// Null constructor
-Magick::ColorMono::ColorMono ( void )
- : Color ()
+Magick::ColorMono::~ColorMono()
{
}
-// Copy constructor from base class
-Magick::ColorMono::ColorMono ( const Magick::Color & color_ )
- : Color( color_ )
-{
-}
-
-// Destructor
-Magick::ColorMono::~ColorMono ()
-{
- // Nothing to do
-}
-
-void Magick::ColorMono::mono ( bool mono_ )
-{
- redQuantum ( mono_ ? QuantumRange : 0 );
- greenQuantum ( mono_ ? QuantumRange : 0 );
- blueQuantum ( mono_ ? QuantumRange : 0 );
-}
-
-bool Magick::ColorMono::mono ( void ) const
-{
- if ( greenQuantum() )
- return true;
- else
- return false;
-}
-
-// Assignment from base class
Magick::ColorMono& Magick::ColorMono::operator = ( const Magick::Color& color_ )
{
*static_cast<Magick::Color*>(this) = color_;
return *this;
}
-//
-// ColorRGB Implementation
-//
-
-// Construct from red, green, and blue, components
-Magick::ColorRGB::ColorRGB ( double red_,
- double green_,
- double blue_ )
- : Color ( scaleDoubleToQuantum(red_),
- scaleDoubleToQuantum(green_),
- scaleDoubleToQuantum(blue_) )
+void Magick::ColorMono::mono(bool mono_)
{
- alphaQuantum ( OpaqueAlpha );
-}
-// Null constructor
-Magick::ColorRGB::ColorRGB ( void )
- : Color ()
-{
-}
-// Copy constructor from base class
-Magick::ColorRGB::ColorRGB ( const Magick::Color & color_ )
- : Color( color_ )
-{
-}
-// Destructor
-Magick::ColorRGB::~ColorRGB ( void )
-{
- // Nothing to do
+ quantumRed(mono_ ? QuantumRange : 0);
+ quantumGreen(mono_ ? QuantumRange : 0);
+ quantumBlue(mono_ ? QuantumRange : 0);
}
-// Assignment from base class
-Magick::ColorRGB& Magick::ColorRGB::operator = ( const Magick::Color& color_ )
+bool Magick::ColorMono::mono(void) const
{
- *static_cast<Magick::Color*>(this) = color_;
- return *this;
+ return(quantumGreen() == 0);
}
-//
-// ColorYUV Implementation
-//
-
-// R = Y +1.13980*V
-// G = Y-0.39380*U-0.58050*V
-// B = Y+2.02790*U
-//
-// U and V, normally -0.5 through 0.5, must be normalized to the range 0
-// through QuantumRange.
-//
-// Y = 0.29900*R+0.58700*G+0.11400*B
-// U = -0.14740*R-0.28950*G+0.43690*B
-// V = 0.61500*R-0.51500*G-0.10000*B
-//
-// U and V, normally -0.5 through 0.5, are normalized to the range 0
-// through QuantumRange. Note that U = 0.493*(B-Y), V = 0.877*(R-Y).
-//
-
-// Construct from color components
-Magick::ColorYUV::ColorYUV ( double y_,
- double u_,
- double v_ )
- : Color ( scaleDoubleToQuantum(y_ + 1.13980 * v_ ),
- scaleDoubleToQuantum(y_ - (0.39380 * u_) - (0.58050 * v_) ),
- scaleDoubleToQuantum(y_ + 2.02790 * u_ ) )
-{
- alphaQuantum ( OpaqueAlpha );
-}
-// Null constructor
-Magick::ColorYUV::ColorYUV ( void )
- : Color ()
+Magick::ColorMono::ColorMono(PixelInfo *rep_,PixelType pixelType_)
+ : Color(rep_,pixelType_)
{
}
-// Copy constructor from base class
-Magick::ColorYUV::ColorYUV ( const Magick::Color & color_ )
- : Color( color_ )
+
+Magick::ColorRGBA::ColorRGBA(void)
+ : Color()
{
}
-// Destructor
-Magick::ColorYUV::~ColorYUV ( void )
+
+Magick::ColorRGBA::ColorRGBA(const Magick::Color & color_)
+ : Color(color_)
{
- // Nothing to do
}
-void Magick::ColorYUV::u ( double u_ )
+Magick::ColorRGBA::ColorRGBA(const double red_,const double green_,
+ const double blue_)
+ : Color(scaleDoubleToQuantum(red_),scaleDoubleToQuantum(green_),
+ scaleDoubleToQuantum(blue_))
{
- double V = v();
- double Y = y();
-
- redQuantum ( scaleDoubleToQuantum( Y + 1.13980 * V ) );
- greenQuantum ( scaleDoubleToQuantum( Y - (0.39380 * u_) - (0.58050 * V) ) );
- blueQuantum ( scaleDoubleToQuantum( Y + 2.02790 * u_ ) );
+ quantumAlpha(OpaqueAlpha);
}
-double Magick::ColorYUV::u ( void ) const
+Magick::ColorRGBA::ColorRGBA(const double red_,const double green_,
+ const double blue_,const double alpha_)
+ : Color(scaleDoubleToQuantum(red_),scaleDoubleToQuantum(green_),
+ scaleDoubleToQuantum(blue_),scaleDoubleToQuantum(alpha_))
{
- return scaleQuantumToDouble( (-0.14740 * redQuantum()) - (0.28950 *
- greenQuantum()) + (0.43690 * blueQuantum()) );
}
-void Magick::ColorYUV::v ( double v_ )
+Magick::ColorRGBA::~ColorRGBA(void)
{
- double U = u();
- double Y = y();
-
- redQuantum ( scaleDoubleToQuantum( Y + 1.13980 * v_ ) );
- greenQuantum ( scaleDoubleToQuantum( Y - (0.39380 * U) - (0.58050 * v_) ) );
- blueQuantum ( scaleDoubleToQuantum( Y + 2.02790 * U ) );
}
-double Magick::ColorYUV::v ( void ) const
+Magick::ColorRGBA& Magick::ColorRGBA::operator=(const Magick::Color& color_)
{
- return scaleQuantumToDouble((0.61500 * redQuantum()) -
- (0.51500 * greenQuantum()) -
- (0.10000 * blueQuantum()));
+ *static_cast<Magick::Color*>(this)=color_;
+ return(*this);
}
-void Magick::ColorYUV::y ( double y_ )
+Magick::ColorYUV::ColorYUV(void)
+ : Color()
{
- double U = u();
- double V = v();
+}
- redQuantum ( scaleDoubleToQuantum( y_ + 1.13980 * V ) );
- greenQuantum ( scaleDoubleToQuantum( y_ - (0.39380 * U) - (0.58050 * V) ) );
- blueQuantum ( scaleDoubleToQuantum( y_ + 2.02790 * U ) );
+Magick::ColorYUV::ColorYUV(const Magick::Color &color_)
+ : Color(color_)
+{
+}
+
+Magick::ColorYUV::ColorYUV(const double y_,const double u_,const double v_)
+ : Color()
+{
+ convert(y_, u_, v_);
+ quantumAlpha(OpaqueAlpha);
+}
+
+Magick::ColorYUV::~ColorYUV(void)
+{
+}
+
+Magick::ColorYUV& Magick::ColorYUV::operator=(const Magick::Color &color_)
+{
+ *static_cast<Magick::Color*>(this)=color_;
+ return(*this);
+}
+
+void Magick::ColorYUV::u(const double u_)
+{
+ convert(y(), u_, v());
+}
+
+double Magick::ColorYUV::u(void) const
+{
+ return scaleQuantumToDouble((-0.14740 * quantumRed()) - (0.28950 *
+ quantumGreen()) + (0.43690 * quantumBlue()));
+}
+
+void Magick::ColorYUV::v(const double v_)
+{
+ convert(y(), u(), v_);
+}
+
+double Magick::ColorYUV::v(void) const
+{
+ return scaleQuantumToDouble((0.61500 * quantumRed()) - (0.51500 *
+ quantumGreen()) - (0.10000 * quantumBlue()));
+}
+
+void Magick::ColorYUV::y(const double y_)
+{
+ convert(y_, u(), v());
}
double Magick::ColorYUV::y ( void ) const
{
- return scaleQuantumToDouble((0.29900 * redQuantum()) +
- (0.58700 * greenQuantum()) +
- (0.11400 * blueQuantum()));
+ return scaleQuantumToDouble((0.29900 * quantumRed()) + (0.58700 *
+ quantumGreen()) + (0.11400 * quantumBlue()));
}
-// Assignment from base class
-Magick::ColorYUV& Magick::ColorYUV::operator = ( const Magick::Color& color_ )
+void Magick::ColorYUV::convert(const double y_,const double u_,const double v_)
{
- *static_cast<Magick::Color*>(this) = color_;
- return *this;
+ quantumRed(scaleDoubleToQuantum(y_ + 1.13980 * v_));
+ quantumGreen(scaleDoubleToQuantum(y_ - (0.39380 * u_) - (0.58050 * v_)));
+ quantumBlue(scaleDoubleToQuantum(y_ + 2.02790 * u_));
}
+
+Magick::ColorYUV::ColorYUV(PixelInfo *rep_,PixelType pixelType_)
+ : Color(rep_,pixelType_)
+{
+}
\ No newline at end of file
diff --git a/Magick++/lib/Magick++/Blob.h b/Magick++/lib/Magick++/Blob.h
index 0bea044..84c6987 100644
--- a/Magick++/lib/Magick++/Blob.h
+++ b/Magick++/lib/Magick++/Blob.h
@@ -44,21 +44,7 @@
// Update object contents from Base64-encoded string representation.
void base64(const std::string base64_);
// Return Base64-encoded string representation.
- std::string base64(void);
-
- // Update object contents, making a copy of the supplied data.
- // Any existing data in the object is deallocated.
- void update(const void* data_,size_t length_);
-
- // Update object contents, using supplied pointer directly (no
- // copy). Any existing data in the object is deallocated. The user
- // must ensure that the pointer supplied is not deleted or
- // otherwise modified after it has been supplied to this method.
- // Specify allocator_ as "MallocAllocator" if memory is allocated
- // via the C language malloc() function, or "NewAllocator" if
- // memory is allocated via C++ 'new'.
- void updateNoCopy(void* data_,size_t length_,
- Allocator allocator_=NewAllocator);
+ std::string base64(void) const;
// Obtain pointer to data. The user should never try to modify or
// free this data since the Blob class manages its own data. The
@@ -70,6 +56,20 @@
// Obtain data length
size_t length(void) const;
+ // Update object contents, making a copy of the supplied data.
+ // Any existing data in the object is deallocated.
+ void update(const void* data_,const size_t length_);
+
+ // Update object contents, using supplied pointer directly (no
+ // copy). Any existing data in the object is deallocated. The user
+ // must ensure that the pointer supplied is not deleted or
+ // otherwise modified after it has been supplied to this method.
+ // Specify allocator_ as "MallocAllocator" if memory is allocated
+ // via the C language malloc() function, or "NewAllocator" if
+ // memory is allocated via C++ 'new'.
+ void updateNoCopy(void* data_,const size_t length_,
+ const Allocator allocator_=NewAllocator);
+
private:
BlobRef *_blobRef;
};
diff --git a/Magick++/lib/Magick++/CoderInfo.h b/Magick++/lib/Magick++/CoderInfo.h
index c3a6b1c..62ad22f 100644
--- a/Magick++/lib/Magick++/CoderInfo.h
+++ b/Magick++/lib/Magick++/CoderInfo.h
@@ -37,6 +37,9 @@
// Destructor
~CoderInfo(void);
+ // Assignment operator
+ CoderInfo& operator=(const CoderInfo &coder_);
+
// Format description
std::string description(void) const;
@@ -55,14 +58,6 @@
// Format name
std::string name(void) const;
- // Assignment operator
- CoderInfo& operator=(const CoderInfo &coder_);
-
- //
- // Implemementation methods
- //
- CoderInfo(const MagickCore::MagickInfo *magickInfo_);
-
private:
std::string _name;
std::string _description;
@@ -74,9 +69,4 @@
} // namespace Magick
-//
-// Inlines
-//
-
-
#endif // Magick_CoderInfo_header
diff --git a/Magick++/lib/Magick++/Color.h b/Magick++/lib/Magick++/Color.h
index 2c3c9a7..d37dc05 100644
--- a/Magick++/lib/Magick++/Color.h
+++ b/Magick++/lib/Magick++/Color.h
@@ -12,110 +12,109 @@
namespace Magick
{
-
class MagickPPExport Color;
// Compare two Color objects regardless of LHS/RHS
- int MagickPPExport operator == ( const Magick::Color& left_, const Magick::Color& right_ );
- int MagickPPExport operator != ( const Magick::Color& left_, const Magick::Color& right_ );
- int MagickPPExport operator > ( const Magick::Color& left_, const Magick::Color& right_ );
- int MagickPPExport operator < ( const Magick::Color& left_, const Magick::Color& right_ );
- int MagickPPExport operator >= ( const Magick::Color& left_, const Magick::Color& right_ );
- int MagickPPExport operator <= ( const Magick::Color& left_, const Magick::Color& right_ );
+ int MagickPPExport operator ==
+ (const Magick::Color& left_,const Magick::Color& right_);
+ int MagickPPExport operator !=
+ (const Magick::Color& left_,const Magick::Color& right_);
+ int MagickPPExport operator >
+ (const Magick::Color& left_,const Magick::Color& right_);
+ int MagickPPExport operator <
+ (const Magick::Color& left_,const Magick::Color& right_);
+ int MagickPPExport operator >=
+ (const Magick::Color& left_,const Magick::Color& right_);
+ int MagickPPExport operator <=
+ (const Magick::Color& left_,const Magick::Color& right_);
- // Base color class stores RGB components scaled to fit Quantum
+ // Base color class stores RGBA components scaled to fit Quantum
+ // All double arguments have a valid range of 0.0 - 1.0.
class MagickPPExport Color
{
public:
- Color ( Quantum red_,
- Quantum green_,
- Quantum blue_ );
- Color ( Quantum red_,
- Quantum green_,
- Quantum blue_,
- Quantum alpha_ );
- Color ( const std::string &x11color_ );
- Color ( const char * x11color_ );
- Color ( void );
- virtual ~Color ( void );
- Color ( const Color & color_ );
- // Red color (range 0 to QuantumRange)
- void redQuantum ( Quantum red_ );
- Quantum redQuantum ( void ) const;
+ // Default constructor
+ Color(void);
- // Green color (range 0 to QuantumRange)
- void greenQuantum ( Quantum green_ );
- Quantum greenQuantum ( void ) const;
+ // Construct Color using the specified RGB values
+ Color(const Quantum red_,const Quantum green_,const Quantum blue_);
- // Blue color (range 0 to QuantumRange)
- void blueQuantum ( Quantum blue_ );
- Quantum blueQuantum ( void ) const;
+ // Construct Color using the specified RGBA values
+ Color(const Quantum red_,const Quantum green_,const Quantum blue_,
+ const Quantum alpha_);
- // Alpha level (range OpaqueAlpha=0 to TransparentAlpha=QuantumRange)
- void alphaQuantum ( Quantum alpha_ );
- Quantum alphaQuantum ( void ) const;
+ // Copy constructor
+ Color(const Color &color_);
- // Scaled (to 1.0) version of alpha for use in sub-classes
- // (range opaque=0 to transparent=1.0)
- void alpha ( double alpha_ );
- double alpha ( void ) const;
-
- // Does object contain valid color?
- void isValid ( bool valid_ );
- bool isValid ( void ) const;
-
- // Set color via X11 color specification string
- const Color& operator= ( const std::string &x11color_ );
- const Color& operator= ( const char * x11color_ );
+ // Construct color via ImageMagick PixelInfo
+ Color(const PixelInfo &color_);
+
+ // Constructor Color using the specified color string
+ Color(const std::string &color_);
+
+ // Destructor
+ virtual ~Color(void);
// Assignment operator
- Color& operator= ( const Color& color_ );
+ Color& operator=(const Color &color_);
- // Return X11 color specification string
- /* virtual */ operator std::string() const;
+ // Set color via ImageMagick PixelInfo
+ const Color& operator=(const PixelInfo &color_);
+
+ // Set color via color specification string
+ const Color& operator=(const std::string &color);
// Return ImageMagick PixelInfo
operator PixelInfo() const;
- // Construct color via ImageMagick PixelInfo
- Color ( const PixelInfo &color_ );
+ // Return color specification string
+ operator std::string() const;
- // Set color via ImageMagick PixelInfo
- const Color& operator= ( const PixelInfo &color_ );
+ // Alpha level (range 0.0=0 to 1.0=QuantumRange)
+ void alpha(const double alpha_);
+ double alpha(void) const;
- //
- // Public methods beyond this point are for Magick++ use only.
- //
+ // Blue color (range 0.0 to 1.0)
+ void blue(const double blue_);
+ double blue(void) const;
- // Obtain pixel intensity as a double
- double intensity ( void ) const
- {
- return (0.299*(_pixel->red)+0.587*(_pixel->green)+0.114*(_pixel->blue));
- }
+ // Green color (range 0 to QuantumRange)
+ void green(const double green_);
+ double green(void) const;
- // Scale a value expressed as a double (0-1) to Quantum range (0-QuantumRange)
- static Quantum scaleDoubleToQuantum( const double double_ )
- {
- return (static_cast<Magick::Quantum>(double_*QuantumRange));
- }
+ // Does object contain valid color?
+ void isValid(const bool valid_);
+ bool isValid(void) const;
- // Scale a value expressed as a Quantum (0-QuantumRange) to double range (0-1)
-#if (MAGICKCORE_QUANTUM_DEPTH < 64)
- static double scaleQuantumToDouble( const Quantum quantum_ )
- {
- return (static_cast<double>(quantum_)/QuantumRange);
- }
-#endif
- static double scaleQuantumToDouble( const double quantum_ )
- {
- return (quantum_/QuantumRange);
- }
+ // Alpha level (range OpaqueAlpha=0 to TransparentAlpha=QuantumRange)
+ void quantumAlpha(const Quantum alpha_);
+ Quantum quantumAlpha(void) const;
+ // Blue color (range 0 to QuantumRange)
+ void quantumBlue(const Quantum blue_);
+ Quantum quantumBlue(void) const;
+
+ // Green color (range 0 to QuantumRange)
+ void quantumGreen(const Quantum green_);
+ Quantum quantumGreen(void) const;
+
+ // Red color (range 0 to QuantumRange)
+ void quantumRed(const Quantum red_);
+ Quantum quantumRed(void) const;
+
+ // Red color (range 0 to 1.0)
+ void red(const double red_);
+ double red(void) const;
protected:
// PixelType specifies the interpretation of PixelInfo members
+ // CYMKPixel:
+ // Cyan = red
+ // Yellow = green
+ // Magenta = blue
+ // Black(K) = alpha
// RGBPixel:
// Red = red;
// Green = green;
@@ -125,155 +124,184 @@
// Green = green;
// Blue = blue;
// Alpha = alpha;
- // CYMKPixel:
- // Cyan = red
- // Yellow = green
- // Magenta = blue
- // Black(K) = alpha
enum PixelType
{
+ CYMKPixel,
RGBPixel,
- RGBAPixel,
- CYMKPixel
+ RGBAPixel
};
// Constructor to construct with PixelInfo*
// Used to point Color at a pixel in an image
- Color ( PixelInfo* rep_, PixelType pixelType_ );
+ Color(PixelInfo *rep_,PixelType pixelType_);
// Set pixel
// Used to point Color at a pixel in an image
- void pixel ( PixelInfo* rep_, PixelType pixelType_ );
+ void pixel(PixelInfo *rep_,PixelType pixelType_);
+
+ // Scale a value expressed as a double (0-1) to Quantum range (0-QuantumRange)
+ static Quantum scaleDoubleToQuantum(const double double_);
+
+ // Scale a value expressed as a Quantum (0-QuantumRange) to double range (0-1)
+ static double scaleQuantumToDouble(const Quantum quantum_);
// PixelInfo represents a color pixel:
// red = red (range 0 to QuantumRange)
// green = green (range 0 to QuantumRange)
// blue = blue (range 0 to QuantumRange)
- // alpha = alpha (range OpaqueAlpha=0 to TransparentAlpha=QuantumRange)
+ // alpha = alpha (range OpaqueAlpha=0 to TransparentAlpha=QuantumRange)
// index = PseudoColor colormap index
- PixelInfo* _pixel;
+ PixelInfo *_pixel;
private:
+ bool _isValid; // Set true if pixel is "valid"
+ bool _pixelOwn; // Set true if we allocated pixel
+ PixelType _pixelType; // Color type supported by _pixel
+
// Common initializer for PixelInfo representation
void initPixel();
-
- // Set true if we allocated pixel
- bool _pixelOwn;
-
- // Set true if pixel is "valid"
- bool _isValid;
-
- // Color type supported by _pixel
- PixelType _pixelType;
-
};
//
- // HSL Colorspace colors
- //
- class MagickPPExport ColorHSL : public Color
- {
- public:
- ColorHSL ( double hue_, double saturation_, double luminosity_ );
- ColorHSL ( void );
- ColorHSL ( const Color & color_ );
- /* virtual */ ~ColorHSL ( );
-
- void hue ( double hue_ );
- double hue ( void ) const;
-
- void saturation ( double saturation_ );
- double saturation ( void ) const;
-
- void luminosity ( double luminosity_ );
- double luminosity ( void ) const;
-
- // Assignment operator from base class
- ColorHSL& operator= ( const Color& color_ );
-
- protected:
- // Constructor to construct with PixelInfo*
- ColorHSL ( PixelInfo* rep_, PixelType pixelType_ );
- };
-
- //
// Grayscale RGB color
//
// Grayscale is simply RGB with equal parts of red, green, and blue
// All double arguments have a valid range of 0.0 - 1.0.
- class MagickPPExport ColorGray : public Color
+ class MagickPPExport ColorGray: public Color
{
public:
- ColorGray ( double shade_ );
- ColorGray ( void );
- ColorGray ( const Color & color_ );
- /* virtual */ ~ColorGray ();
- void shade ( double shade_ );
- double shade ( void ) const;
+ // Default constructor
+ ColorGray(void);
+
+ // Copy constructor
+ ColorGray(const Color &color_);
+
+ // Construct ColorGray using the specified shade
+ ColorGray(const double shade_);
+
+ // Destructor
+ ~ColorGray();
+
+ // Shade
+ void shade(const double shade_);
+ double shade(void) const;
// Assignment operator from base class
- ColorGray& operator= ( const Color& color_ );
+ ColorGray& operator=(const Color& color_);
protected:
+
// Constructor to construct with PixelInfo*
- ColorGray ( PixelInfo* rep_, PixelType pixelType_ );
+ ColorGray(PixelInfo *rep_,PixelType pixelType_);
};
-
+
+ //
+ // HSL Colorspace colors
+ //
+ // All double arguments have a valid range of 0.0 - 1.0.
+ class MagickPPExport ColorHSL: public Color
+ {
+ public:
+
+ // Default constructor
+ ColorHSL(void);
+
+ // Copy constructor
+ ColorHSL(const Color &color_);
+
+ // Construct ColorHSL using the specified HSL values
+ ColorHSL(const double hue_,const double saturation_,
+ const double luminosity_);
+
+ // Destructor
+ ~ColorHSL();
+
+ // Assignment operator from base class
+ ColorHSL& operator=(const Color& color_);
+
+ // Hue color
+ void hue(const double hue_);
+ double hue(void) const;
+
+ // Luminosity color
+ void luminosity(const double luminosity_);
+ double luminosity(void) const;
+
+ // Saturation color
+ void saturation(const double saturation_);
+ double saturation(void) const;
+
+ protected:
+
+ // Constructor to construct with PixelInfo*
+ ColorHSL(PixelInfo *rep_,PixelType pixelType_);
+ };
+
//
// Monochrome color
//
// Color arguments are constrained to 'false' (black pixel) and 'true'
// (white pixel)
- class MagickPPExport ColorMono : public Color
+ class MagickPPExport ColorMono: public Color
{
public:
- ColorMono ( bool mono_ );
- ColorMono ( void );
- ColorMono ( const Color & color_ );
- /* virtual */ ~ColorMono ();
-
- void mono ( bool mono_ );
- bool mono ( void ) const;
+
+ // Default constructor
+ ColorMono(void);
+
+ // Construct ColorMono (false=black, true=white)
+ ColorMono(const bool mono_);
+
+ // Copy constructor
+ ColorMono(const Color &color_);
+
+ // Destructor
+ ~ColorMono();
// Assignment operator from base class
- ColorMono& operator= ( const Color& color_ );
+ ColorMono& operator=(const Color& color_);
+
+ // Mono color
+ void mono(const bool mono_);
+ bool mono(void) const;
protected:
+
// Constructor to construct with PixelInfo*
- ColorMono ( PixelInfo* rep_, PixelType pixelType_ );
+ ColorMono(PixelInfo* rep_,PixelType pixelType_);
};
-
- //
- // RGB color
- //
- // All color arguments have a valid range of 0.0 - 1.0.
- class MagickPPExport ColorRGB : public Color
+
+ class MagickPPExport ColorRGBA: public Color
{
public:
- ColorRGB ( double red_, double green_, double blue_ );
- ColorRGB ( void );
- ColorRGB ( const Color & color_ );
- /* virtual */ ~ColorRGB ( void );
-
- void red ( double red_ );
- double red ( void ) const;
-
- void green ( double green_ );
- double green ( void ) const;
-
- void blue ( double blue_ );
- double blue ( void ) const;
+
+ // Default constructor
+ ColorRGBA(void);
+
+ // Copy constructor
+ ColorRGBA(const Color &color_);
+
+ // Construct ColorRGBA using the specified RGB values
+ ColorRGBA(const double red_,const double green_,const double blue_);
+
+ // Construct ColorRGBA using the specified RGBA values
+ ColorRGBA(const double red_,const double green_,const double blue_,
+ const double alpha);
+
+ // Destructor
+ ~ColorRGBA(void);
// Assignment operator from base class
- ColorRGB& operator= ( const Color& color_ );
+ ColorRGBA& operator=(const Color& color_);
protected:
+
// Constructor to construct with PixelInfo*
- ColorRGB ( PixelInfo* rep_, PixelType pixelType_ );
+ ColorRGBA(PixelInfo *rep_,PixelType pixelType_);
};
-
+
//
// YUV Colorspace color
//
@@ -281,184 +309,47 @@
// Y: 0.0 through 1.0
// U: -0.5 through 0.5
// V: -0.5 through 0.5
- class MagickPPExport ColorYUV : public Color
+ class MagickPPExport ColorYUV: public Color
{
public:
- ColorYUV ( double y_, double u_, double v_ );
- ColorYUV ( void );
- ColorYUV ( const Color & color_ );
- /* virtual */ ~ColorYUV ( void );
-
- void u ( double u_ );
- double u ( void ) const;
-
- void v ( double v_ );
- double v ( void ) const;
-
- void y ( double y_ );
- double y ( void ) const;
+
+ // Default constructor
+ ColorYUV(void);
+
+ // Copy constructor
+ ColorYUV(const Color &color_);
+
+ // Construct ColorYUV using the specified YUV values
+ ColorYUV(const double y_,const double u_,const double v_);
+
+ // Destructor
+ ~ColorYUV(void);
// Assignment operator from base class
- ColorYUV& operator= ( const Color& color_ );
+ ColorYUV& operator=(const Color& color_);
+
+ // Color U (0.0 through 1.0)
+ void u(const double u_);
+ double u(void) const;
+
+ // Color V (-0.5 through 0.5)
+ void v(const double v_);
+ double v(void) const;
+
+ // Color Y (-0.5 through 0.5)
+ void y(const double y_);
+ double y(void) const;
protected:
+
// Constructor to construct with PixelInfo*
- ColorYUV ( PixelInfo* rep_, PixelType pixelType_ );
+ ColorYUV(PixelInfo *rep_,PixelType pixelType_);
+
+ private:
+
+ void convert(const double y_,const double u_,const double v_);
+
};
} // namespace Magick
-//
-// Inlines
-//
-
-//
-// Color
-//
-
-// Common initializer for PixelInfo representation
-// Initialized transparent black
-inline void Magick::Color::initPixel()
-{
- _pixel->red = 0;
- _pixel->green = 0;
- _pixel->blue = 0;
- _pixel->alpha = TransparentAlpha;
-}
-
-inline void Magick::Color::redQuantum ( Magick::Quantum red_ )
-{
- _pixel->red = (double) red_;
- _isValid = true;
-}
-
-inline Magick::Quantum Magick::Color::redQuantum ( void ) const
-{
- return MagickCore::ClampToQuantum(_pixel->red);
-}
-
-inline void Magick::Color::greenQuantum ( Magick::Quantum green_ )
-{
- _pixel->green = (double) green_;
- _isValid = true;
-}
-
-inline Magick::Quantum Magick::Color::greenQuantum ( void ) const
-{
- return MagickCore::ClampToQuantum(_pixel->green);
-}
-
-inline void Magick::Color::blueQuantum ( Magick::Quantum blue_ )
-{
- _pixel->blue = (double) blue_;
- _isValid = true;
-}
-
-inline Magick::Quantum Magick::Color::blueQuantum ( void ) const
-{
- return MagickCore::ClampToQuantum(_pixel->blue);
-}
-
-inline void Magick::Color::alphaQuantum ( Magick::Quantum alpha_ )
-{
- _pixel->alpha = alpha_;
- _isValid = true ;
-}
-
-inline Magick::Quantum Magick::Color::alphaQuantum ( void ) const
-{
- return MagickCore::ClampToQuantum(_pixel->alpha);
-}
-
-// Return ImageMagick PixelInfo struct based on color.
-inline Magick::Color::operator MagickCore::PixelInfo () const
-{
- return *_pixel;
-}
-
-// Scaled version of alpha for use in sub-classes
-inline void Magick::Color::alpha ( double alpha_ )
-{
- alphaQuantum( scaleDoubleToQuantum(alpha_) );
-}
-inline double Magick::Color::alpha ( void ) const
-{
- return scaleQuantumToDouble( alphaQuantum() );
-}
-
-//
-// ColorHSL
-//
-inline Magick::ColorHSL::ColorHSL ( Magick::PixelInfo* rep_,
- Magick::Color::PixelType pixelType_ )
-: Color( rep_, pixelType_ )
-{
-}
-
-//
-// ColorGray
-//
-inline Magick::ColorGray::ColorGray ( Magick::PixelInfo* rep_,
- Magick::Color::PixelType pixelType_ )
-: Color( rep_, pixelType_ )
-{
-}
-
-//
-// ColorMono
-//
-inline Magick::ColorMono::ColorMono ( Magick::PixelInfo* rep_,
- Magick::Color::PixelType pixelType_ )
- : Color( rep_, pixelType_ )
-{
-}
-
-//
-// ColorRGB
-//
-inline Magick::ColorRGB::ColorRGB ( Magick::PixelInfo* rep_,
- Magick::Color::PixelType pixelType_ )
- : Color( rep_, pixelType_ )
-{
-}
-
-inline void Magick::ColorRGB::red ( double red_ )
-{
- redQuantum( scaleDoubleToQuantum(red_) );
-}
-
-inline double Magick::ColorRGB::red ( void ) const
-{
- return scaleQuantumToDouble( redQuantum() );
-}
-
-inline void Magick::ColorRGB::green ( double green_ )
-{
- greenQuantum( scaleDoubleToQuantum(green_) );
-}
-
-inline double Magick::ColorRGB::green ( void ) const
-{
- return scaleQuantumToDouble( greenQuantum() );
-}
-
-inline void Magick::ColorRGB::blue ( double blue_ )
-{
- blueQuantum( scaleDoubleToQuantum(blue_) );
-}
-
-inline double Magick::ColorRGB::blue ( void ) const
-{
- return scaleQuantumToDouble( blueQuantum() );
-}
-
-//
-// ColorYUV
-//
-
-inline Magick::ColorYUV::ColorYUV ( Magick::PixelInfo* rep_,
- Magick::Color::PixelType pixelType_ )
- : Color( rep_, pixelType_ )
-{
-}
-
#endif // Magick_Color_header
diff --git a/Magick++/lib/Magick++/STL.h b/Magick++/lib/Magick++/STL.h
index 95ef0e1..7c10702 100644
--- a/Magick++/lib/Magick++/STL.h
+++ b/Magick++/lib/Magick++/STL.h
@@ -2513,13 +2513,13 @@
names_->clear();
- MagickCore::ResetImageProfileIterator( image_->constImage() );
- name=MagickCore::GetNextImageProfile( image_->constImage() );
- while (name != (const char *) NULL)
- {
- names_->push_back( std::string(name) );
- name=MagickCore::GetNextImageProfile( image_->constImage() );
- }
+ MagickCore::ResetImageProfileIterator( image_->constImage() );
+ name=MagickCore::GetNextImageProfile( image_->constImage() );
+ while (name != (const char *) NULL)
+ {
+ names_->push_back( std::string(name) );
+ name=MagickCore::GetNextImageProfile( image_->constImage() );
+ }
}
// Quantize colors in images using current quantization settings
diff --git a/Magick++/tests/attributes.cpp b/Magick++/tests/attributes.cpp
index c065f24..4048be7 100644
--- a/Magick++/tests/attributes.cpp
+++ b/Magick++/tests/attributes.cpp
@@ -154,7 +154,7 @@
//
// Test default value.
- if ( image.backgroundColor() != ColorRGB("white") )
+ if ( image.backgroundColor() != ColorRGBA("white") )
{
++failures;
cout << "Line: " << __LINE__ << ", backgroundColor default ("
@@ -288,7 +288,7 @@
//
// borderColor
//
- if ( image.borderColor() != ColorRGB("#dfdfdf") )
+ if ( image.borderColor() != ColorRGBA("#dfdfdf") )
{
++failures;
cout << "Line: " << __LINE__
@@ -941,8 +941,8 @@
}
// Test set/get
- image.matteColor(ColorRGB(0.5,0.5,1));
- if ( image.matteColor() != ColorRGB(0.5,0.5,1) )
+ image.matteColor(ColorRGBA(0.5,0.5,1));
+ if ( image.matteColor() != ColorRGBA(0.5,0.5,1) )
{
++failures;
cout << "Line: " << __LINE__ << ", matteColor set/get failed" << endl;
@@ -1028,8 +1028,8 @@
// penColor
//
- image.penColor(ColorRGB(0.5,0.5,1));
- if ( image.penColor() != ColorRGB(0.5,0.5,1) )
+ image.penColor(ColorRGBA(0.5,0.5,1));
+ if ( image.penColor() != ColorRGBA(0.5,0.5,1) )
{
++failures;
cout << "Line: " << __LINE__ << ", penColor ("
@@ -1041,8 +1041,8 @@
// strokeColor
//
- image.strokeColor(ColorRGB(0.5,0.5,1));
- if ( image.strokeColor() != ColorRGB(0.5,0.5,1) )
+ image.strokeColor(ColorRGBA(0.5,0.5,1));
+ if ( image.strokeColor() != ColorRGBA(0.5,0.5,1) )
{
++failures;
cout << "Line: " << __LINE__ << ", strokeColor ("
@@ -1055,8 +1055,8 @@
// fillColor
//
- image.fillColor(ColorRGB(0.5,0.5,1));
- if ( image.fillColor() != ColorRGB(0.5,0.5,1) )
+ image.fillColor(ColorRGBA(0.5,0.5,1));
+ if ( image.fillColor() != ColorRGBA(0.5,0.5,1) )
{
++failures;
cout << "Line: " << __LINE__ << ", fillColor ("
@@ -1079,8 +1079,8 @@
}
// Test set/get
- image.pixelColor(40,60, ColorRGB(0.5,1,1));
- if ( image.pixelColor(40,60) != ColorRGB(0.5,1,1) )
+ image.pixelColor(40,60, ColorRGBA(0.5,1,1));
+ if ( image.pixelColor(40,60) != ColorRGBA(0.5,1,1) )
{
++failures;
cout << "Line: " << __LINE__ << ", pixelColor set/get failed" << endl;
diff --git a/Magick++/tests/color.cpp b/Magick++/tests/color.cpp
index 0ce2ebc..bfbcaf4 100644
--- a/Magick++/tests/color.cpp
+++ b/Magick++/tests/color.cpp
@@ -24,7 +24,7 @@
try {
//
- // Verify conversion from named colors as well as ColorRGB constructor
+ // Verify conversion from named colors as well as ColorRGBA constructor
//
{
@@ -54,7 +54,7 @@
{
{
Color color( colorMap[i].color );
- ColorRGB colorMatch( colorMap[i].red,
+ ColorRGBA colorMatch( colorMap[i].red,
colorMap[i].green,
colorMap[i].blue );
if ( color != colorMatch )