Powered by Pair ImageMagick logo
Image Magick
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages

Magick::Color Class Reference

#include <Color.h>

Inheritance diagram for Magick::Color:

Inheritance graph
[legend]
Collaboration diagram for Magick::Color:

Collaboration graph
[legend]

Public Member Functions

 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_)
void redQuantum (Quantum red_)
Quantum redQuantum (void) const
void greenQuantum (Quantum green_)
Quantum greenQuantum (void) const
void blueQuantum (Quantum blue_)
Quantum blueQuantum (void) const
void alphaQuantum (Quantum alpha_)
Quantum alphaQuantum (void) const
void alpha (double alpha_)
double alpha (void) const
void isValid (bool valid_)
bool isValid (void) const
const Coloroperator= (const std::string &x11color_)
const Coloroperator= (const char *x11color_)
Coloroperator= (const Color &color_)
 operator std::string () const
 operator PixelPacket () const
 Color (const PixelPacket &color_)
const Coloroperator= (const PixelPacket &color_)
double intensity (void) const
 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_)
void redQuantum (Quantum red_)
Quantum redQuantum (void) const
void greenQuantum (Quantum green_)
Quantum greenQuantum (void) const
void blueQuantum (Quantum blue_)
Quantum blueQuantum (void) const
void alphaQuantum (Quantum alpha_)
Quantum alphaQuantum (void) const
void alpha (double alpha_)
double alpha (void) const
void isValid (bool valid_)
bool isValid (void) const
const Coloroperator= (const std::string &x11color_)
const Coloroperator= (const char *x11color_)
Coloroperator= (const Color &color_)
 operator std::string () const
 operator PixelPacket () const
 Color (const PixelPacket &color_)
const Coloroperator= (const PixelPacket &color_)
double intensity (void) const

Static Public Member Functions

Quantum scaleDoubleToQuantum (const double double_)
double scaleQuantumToDouble (const Quantum quantum_)
double scaleQuantumToDouble (const double quantum_)
Quantum scaleDoubleToQuantum (const double double_)
double scaleQuantumToDouble (const Quantum quantum_)
double scaleQuantumToDouble (const double quantum_)

Protected Types

enum  PixelType { RGBPixel, RGBAPixel, CYMKPixel }
enum  PixelType { RGBPixel, RGBAPixel, CYMKPixel }

Protected Member Functions

 Color (PixelPacket *rep_, PixelType pixelType_)
void pixel (PixelPacket *rep_, PixelType pixelType_)
 Color (PixelPacket *rep_, PixelType pixelType_)
void pixel (PixelPacket *rep_, PixelType pixelType_)

Protected Attributes

PixelPacket_pixel
PixelPacket_pixel

Private Member Functions

void initPixel ()
void initPixel ()

Private Attributes

bool _pixelOwn
PixelType _pixelType

Member Enumeration Documentation

enum Magick::Color::PixelType [protected]
 

Enumeration values:
RGBPixel 
RGBAPixel 
CYMKPixel 

Definition at line 131 of file Color.h.

00132 { 00133 RGBPixel, 00134 RGBAPixel, 00135 CYMKPixel 00136 };

enum Magick::Color::PixelType [protected]
 

Enumeration values:
RGBPixel 
RGBAPixel 
CYMKPixel 

Definition at line 131 of file Color.h.

00132 { 00133 RGBPixel, 00134 RGBAPixel, 00135 CYMKPixel 00136 };


Constructor & Destructor Documentation

Magick::Color::Color Quantum  red_,
Quantum  green_,
Quantum  blue_
 

Definition at line 85 of file Color.cpp.

References alphaQuantum(), blueQuantum(), greenQuantum(), OpaqueOpacity, and redQuantum().

00088 : _pixel(new PixelPacket), 00089 _pixelOwn(true), 00090 _pixelType(RGBPixel) 00091 { 00092 redQuantum ( red_ ); 00093 greenQuantum ( green_ ); 00094 blueQuantum ( blue_ ); 00095 alphaQuantum ( OpaqueOpacity ); 00096 }

Here is the call graph for this function:

Magick::Color::Color Quantum  red_,
Quantum  green_,
Quantum  blue_,
Quantum  alpha_
 

Definition at line 99 of file Color.cpp.

References alphaQuantum(), blueQuantum(), greenQuantum(), and redQuantum().

00103 : _pixel(new PixelPacket), 00104 _pixelOwn(true), 00105 _pixelType(RGBAPixel) 00106 { 00107 redQuantum ( red_ ); 00108 greenQuantum ( green_ ); 00109 blueQuantum ( blue_ ); 00110 alphaQuantum ( alpha_ ); 00111 }

Here is the call graph for this function:

Magick::Color::Color const std::string &  x11color_  ) 
 

Definition at line 123 of file Color.cpp.

References initPixel().

00124 : _pixel(new PixelPacket), 00125 _pixelOwn(true), 00126 _pixelType(RGBPixel) 00127 { 00128 initPixel(); 00129 00130 // Use operator = implementation 00131 *this = x11color_; 00132 }

Here is the call graph for this function:

Magick::Color::Color const char *  x11color_  ) 
 

Definition at line 135 of file Color.cpp.

References initPixel().

00136 : _pixel(new PixelPacket), 00137 _pixelOwn(true), 00138 _pixelType(RGBPixel) 00139 { 00140 initPixel(); 00141 00142 // Use operator = implementation 00143 *this = x11color_; 00144 }

Here is the call graph for this function:

Magick::Color::Color void   ) 
 

Definition at line 76 of file Color.cpp.

References initPixel().

00077 : _pixel(new PixelPacket), 00078 _pixelOwn(true), 00079 _pixelType(RGBPixel) 00080 { 00081 initPixel(); 00082 }

Here is the call graph for this function:

Magick::Color::~Color void   )  [virtual]
 

Definition at line 168 of file Color.cpp.

References _pixel, and _pixelOwn.

00169 { 00170 if ( _pixelOwn ) 00171 delete _pixel; 00172 _pixel=0; 00173 }

Magick::Color::Color const Color color_  ) 
 

Definition at line 114 of file Color.cpp.

References _pixel.

00115 : _pixel( new PixelPacket ), 00116 _pixelOwn( true ), 00117 _pixelType( color_._pixelType ) 00118 { 00119 *_pixel = *color_._pixel; 00120 }

Magick::Color::Color const PixelPacket color_  ) 
 

Definition at line 147 of file Color.cpp.

References _pixel, _pixelType, OpaqueOpacity, and RGBAPixel.

00148 : _pixel(new PixelPacket), 00149 _pixelOwn(true), // We allocated this pixel 00150 _pixelType(RGBPixel) // RGB pixel by default 00151 { 00152 *_pixel = color_; 00153 00154 if ( color_.opacity != OpaqueOpacity ) 00155 _pixelType = RGBAPixel; 00156 }

Magick::Color::Color PixelPacket rep_,
PixelType  pixelType_
[protected]
 

Definition at line 160 of file Color.cpp.

00161 : _pixel(rep_), 00162 _pixelOwn(false), 00163 _pixelType(pixelType_) 00164 { 00165 }

Magick::Color::Color Quantum  red_,
Quantum  green_,
Quantum  blue_
 

Magick::Color::Color Quantum  red_,
Quantum  green_,
Quantum  blue_,
Quantum  alpha_
 

Magick::Color::Color const std::string &  x11color_  ) 
 

Magick::Color::Color const char *  x11color_  ) 
 

Magick::Color::Color void   ) 
 

virtual Magick::Color::~Color void   )  [virtual]
 

Magick::Color::Color const Color color_  ) 
 

Magick::Color::Color const PixelPacket color_  ) 
 

Magick::Color::Color PixelPacket rep_,
PixelType  pixelType_
[protected]
 


Member Function Documentation

double Magick::Color::alpha void   )  const
 

void Magick::Color::alpha double  alpha_  ) 
 

double Magick::Color::alpha void   )  const [inline]
 

Definition at line 375 of file Color.h.

References alphaQuantum(), and scaleQuantumToDouble().

00376 { 00377 return scaleQuantumToDouble( alphaQuantum() ); 00378 }

Here is the call graph for this function:

void Magick::Color::alpha double  alpha_  )  [inline]
 

Definition at line 371 of file Color.h.

References alphaQuantum(), and scaleDoubleToQuantum().

00372 { 00373 alphaQuantum( scaleDoubleToQuantum(alpha_) ); 00374 }

Here is the call graph for this function:

Quantum Magick::Color::alphaQuantum void   )  const
 

void Magick::Color::alphaQuantum Quantum  alpha_  ) 
 

Magick::Quantum Magick::Color::alphaQuantum void   )  const [inline]
 

Definition at line 359 of file Color.h.

References _pixel, and _PixelPacket::opacity.

Referenced by alpha(), Color(), Magick::ColorGray::ColorGray(), Magick::ColorHSL::ColorHSL(), Magick::ColorMono::ColorMono(), Magick::ColorRGB::ColorRGB(), Magick::ColorYUV::ColorYUV(), and operator=().

00360 { 00361 return _pixel->opacity; 00362 }

void Magick::Color::alphaQuantum Quantum  alpha_  )  [inline]
 

Definition at line 354 of file Color.h.

References _pixel, and _PixelPacket::opacity.

00355 { 00356 _pixel->opacity = alpha_; 00357 }

Quantum Magick::Color::blueQuantum void   )  const
 

void Magick::Color::blueQuantum Quantum  blue_  ) 
 

Magick::Quantum Magick::Color::blueQuantum void   )  const [inline]
 

Definition at line 349 of file Color.h.

References _pixel, and _PixelPacket::blue.

Referenced by Magick::ColorRGB::blue(), Color(), Magick::ColorHSL::ColorHSL(), Magick::ColorHSL::hue(), Magick::ColorHSL::luminosity(), Magick::ColorMono::mono(), operator=(), Magick::ColorHSL::saturation(), Magick::ColorGray::shade(), Magick::ColorYUV::u(), Magick::ColorYUV::v(), and Magick::ColorYUV::y().

00350 { 00351 return _pixel->blue; 00352 }

void Magick::Color::blueQuantum Quantum  blue_  )  [inline]
 

Definition at line 344 of file Color.h.

References _pixel, and _PixelPacket::blue.

Referenced by Magick::Image::backgroundColor(), Magick::Image::borderColor(), Magick::Image::matteColor(), Magick::operator<(), and Magick::operator==().

00345 { 00346 _pixel->blue = blue_; 00347 }

Quantum Magick::Color::greenQuantum void   )  const
 

void Magick::Color::greenQuantum Quantum  green_  ) 
 

Magick::Quantum Magick::Color::greenQuantum void   )  const [inline]
 

Definition at line 339 of file Color.h.

References _pixel, and _PixelPacket::green.

Referenced by Color(), Magick::ColorHSL::ColorHSL(), Magick::ColorRGB::green(), Magick::ColorHSL::hue(), Magick::ColorHSL::luminosity(), Magick::ColorMono::mono(), operator=(), Magick::ColorHSL::saturation(), Magick::ColorGray::shade(), Magick::ColorYUV::u(), Magick::ColorYUV::v(), and Magick::ColorYUV::y().

00340 { 00341 return _pixel->green; 00342 }

void Magick::Color::greenQuantum Quantum  green_  )  [inline]
 

Definition at line 334 of file Color.h.

References _pixel, and _PixelPacket::green.

Referenced by Magick::Image::backgroundColor(), Magick::Image::borderColor(), Magick::Image::matteColor(), Magick::operator<(), and Magick::operator==().

00335 { 00336 _pixel->green = green_; 00337 }

void Magick::Color::initPixel  )  [private]
 

void Magick::Color::initPixel  )  [inline, private]
 

Definition at line 316 of file Color.h.

References _pixel, _PixelPacket::blue, _PixelPacket::green, _PixelPacket::opacity, _PixelPacket::red, and TransparentOpacity.

Referenced by Color(), isValid(), and operator=().

00317 { 00318 _pixel->red = 0; 00319 _pixel->green = 0; 00320 _pixel->blue = 0; 00321 _pixel->opacity = TransparentOpacity; 00322 }

double Magick::Color::intensity void   )  const [inline]
 

Definition at line 92 of file Color.h.

00093 { 00094 return (0.299*(_pixel->red)+0.587*(_pixel->green)+0.114*(_pixel->blue)); 00095 }

double Magick::Color::intensity void   )  const [inline]
 

Definition at line 92 of file Color.h.

Referenced by Magick::operator<().

00093 { 00094 return (0.299*(_pixel->red)+0.587*(_pixel->green)+0.114*(_pixel->blue)); 00095 }

bool Magick::Color::isValid void   )  const
 

void Magick::Color::isValid bool  valid_  ) 
 

bool Magick::Color::isValid void   )  const
 

Definition at line 269 of file Color.cpp.

References _pixel, _PixelPacket::blue, _PixelPacket::green, _PixelPacket::opacity, _PixelPacket::red, and TransparentOpacity.

Referenced by isValid(), and operator std::string().

00270 { 00271 return( _pixel->opacity != TransparentOpacity || 00272 _pixel->red != 0 || 00273 _pixel->green != 0 || 00274 _pixel->blue != 0 ); 00275 }

void Magick::Color::isValid bool  valid_  ) 
 

Definition at line 276 of file Color.cpp.

References _pixel, _pixelOwn, initPixel(), and isValid().

Referenced by Magick::Image::backgroundColor(), Magick::Image::borderColor(), Magick::Image::colorize(), Magick::Image::colorMap(), Magick::Image::matteColor(), Magick::Image::opaque(), Magick::floodFillTextureImage::operator()(), Magick::floodFillColorImage::operator()(), Magick::operator==(), Magick::Image::pixelColor(), and Magick::Image::transparent().

00277 { 00278 if ( (valid_ && isValid()) || (!valid_ && !isValid()) ) 00279 return; 00280 00281 if ( !_pixelOwn ) 00282 { 00283 _pixel = new PixelPacket; 00284 _pixelOwn = true; 00285 } 00286 00287 initPixel(); 00288 }

Here is the call graph for this function:

Magick::Color::operator PixelPacket  )  const
 

Magick::Color::operator PixelPacket  )  const
 

Magick::Color::operator std::string  )  const
 

Magick::Color::operator std::string  )  const
 

Definition at line 224 of file Color.cpp.

References _pixel, _pixelType, _PixelPacket::blue, _MagickPixelPacket::blue, _MagickPixelPacket::colorspace, _MagickPixelPacket::depth, GetColorTuple(), _PixelPacket::green, _MagickPixelPacket::green, isValid(), MagickFalse, MagickPixelPacket, MagickTrue, _MagickPixelPacket::matte, MaxTextExtent, _PixelPacket::opacity, _MagickPixelPacket::opacity, pixel(), QuantumDepth, _PixelPacket::red, _MagickPixelPacket::red, RGBAPixel, and RGBColorspace.

00225 { 00226 if ( !isValid() ) 00227 return std::string("none"); 00228 00229 char colorbuf[MaxTextExtent]; 00230 00231 MagickPixelPacket 00232 pixel; 00233 00234 pixel.colorspace=RGBColorspace; 00235 pixel.matte=_pixelType == RGBAPixel ? MagickTrue : MagickFalse; 00236 pixel.depth=QuantumDepth; 00237 pixel.red=_pixel->red; 00238 pixel.green=_pixel->green; 00239 pixel.blue=_pixel->blue; 00240 pixel.opacity=_pixel->opacity; 00241 GetColorTuple( &pixel, MagickTrue, colorbuf ); 00242 00243 return std::string(colorbuf); 00244 }

Here is the call graph for this function:

const Color& Magick::Color::operator= const PixelPacket color_  ) 
 

Color& Magick::Color::operator= const Color color_  ) 
 

Reimplemented in Magick::ColorHSL, Magick::ColorGray, Magick::ColorMono, Magick::ColorRGB, Magick::ColorYUV, Magick::ColorHSL, Magick::ColorGray, Magick::ColorMono, Magick::ColorRGB, and Magick::ColorYUV.

const Color& Magick::Color::operator= const char *  x11color_  ) 
 

const Color& Magick::Color::operator= const std::string &  x11color_  ) 
 

const Color& Magick::Color::operator= const PixelPacket color_  ) 
 

Magick::Color & Magick::Color::operator= const Color color_  ) 
 

Reimplemented in Magick::ColorHSL, Magick::ColorGray, Magick::ColorMono, Magick::ColorRGB, Magick::ColorYUV, Magick::ColorHSL, Magick::ColorGray, Magick::ColorMono, Magick::ColorRGB, and Magick::ColorYUV.

Definition at line 176 of file Color.cpp.

References _pixel, and _pixelType.

00177 { 00178 // If not being set to ourself 00179 if ( this != &color_ ) 00180 { 00181 // Copy pixel value 00182 *_pixel = *color_._pixel; 00183 00184 // Copy pixel type 00185 _pixelType = color_._pixelType; 00186 } 00187 return *this; 00188 }

const Magick::Color & Magick::Color::operator= const char *  x11color_  ) 
 

Definition at line 217 of file Color.cpp.

00218 { 00219 *this = std::string(x11color_); 00220 return *this; 00221 }

const Magick::Color & Magick::Color::operator= const std::string &  x11color_  ) 
 

Definition at line 191 of file Color.cpp.

References _pixelType, alphaQuantum(), _PixelPacket::blue, blueQuantum(), DestroyExceptionInfo(), ExceptionInfo, GetExceptionInfo(), _PixelPacket::green, greenQuantum(), initPixel(), _PixelPacket::opacity, OpaqueOpacity, QueryColorDatabase(), _PixelPacket::red, redQuantum(), RGBAPixel, RGBPixel, and Magick::throwException().

00192 { 00193 initPixel(); 00194 PixelPacket target_color; 00195 ExceptionInfo exception; 00196 GetExceptionInfo( &exception ); 00197 if ( QueryColorDatabase( x11color_.c_str(), &target_color, &exception ) ) 00198 { 00199 redQuantum( target_color.red ); 00200 greenQuantum( target_color.green ); 00201 blueQuantum( target_color.blue ); 00202 alphaQuantum( target_color.opacity ); 00203 00204 if ( target_color.opacity > OpaqueOpacity ) 00205 _pixelType = RGBAPixel; 00206 else 00207 _pixelType = RGBPixel; 00208 } 00209 else 00210 throwException(exception); 00211 DestroyExceptionInfo( &exception ); 00212 00213 return *this; 00214 }

Here is the call graph for this function:

void Magick::Color::pixel PixelPacket rep_,
PixelType  pixelType_
[protected]
 

void Magick::Color::pixel PixelPacket rep_,
PixelType  pixelType_
[protected]
 

Definition at line 259 of file Color.cpp.

References _pixel, _pixelOwn, _pixelType, and pixel().

Referenced by operator std::string(), and pixel().

00260 { 00261 if ( _pixelOwn ) 00262 delete _pixel; 00263 _pixel = rep_; 00264 _pixelOwn = false; 00265 _pixelType = pixelType_; 00266 }

Here is the call graph for this function:

Quantum Magick::Color::redQuantum void   )  const
 

void Magick::Color::redQuantum Quantum  red_  ) 
 

Magick::Quantum Magick::Color::redQuantum void   )  const [inline]
 

Definition at line 329 of file Color.h.

References _pixel, and _PixelPacket::red.

Referenced by Color(), Magick::ColorHSL::ColorHSL(), Magick::ColorHSL::hue(), Magick::ColorHSL::luminosity(), Magick::ColorMono::mono(), operator=(), Magick::ColorRGB::red(), Magick::ColorHSL::saturation(), Magick::ColorGray::shade(), Magick::ColorYUV::u(), Magick::ColorYUV::v(), and Magick::ColorYUV::y().

00330 { 00331 return _pixel->red; 00332 }

void Magick::Color::redQuantum Quantum  red_  )  [inline]
 

Definition at line 324 of file Color.h.

References _pixel, and _PixelPacket::red.

R