Magick++ 6.9.13
Loading...
Searching...
No Matches
Magick::Color Class Reference
Inheritance diagram for Magick::Color:
Collaboration diagram for Magick::Color:

Public Member Functions

 Color (Magick::Quantum red_, Magick::Quantum green_, Magick::Quantum blue_)
 
 Color (Magick::Quantum red_, Magick::Quantum green_, Magick::Quantum blue_, Magick::Quantum alpha_)
 
 Color (const char *x11color_)
 
 Color (const Color &color_)
 
 Color (const PixelPacket &color_)
 
 Color (const std::string &x11color_)
 
Coloroperator= (const Color &color_)
 
const Coloroperator= (const char *x11color)
 
const Coloroperator= (const std::string &x11color_)
 
const Coloroperator= (const PixelPacket &color_)
 
 operator PixelPacket () const
 
 operator std::string () const
 
void alpha (double alpha_)
 
double alpha (void) const
 
void alphaQuantum (Quantum alpha_)
 
Quantum alphaQuantum (void) const
 
void blueQuantum (Quantum blue_)
 
Quantum blueQuantum (void) const
 
void greenQuantum (Quantum green_)
 
Quantum greenQuantum (void) const
 
void isValid (bool valid_)
 
bool isValid (void) const
 
void redQuantum (Quantum red_)
 
Quantum redQuantum (void) const
 
double intensity (void) const
 

Static Public Member Functions

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

Protected Types

enum  PixelType { RGBPixel , RGBAPixel , CYMKPixel }
 

Protected Member Functions

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

Protected Attributes

PixelPacket * _pixel
 

Private Member Functions

void initPixel ()
 

Private Attributes

bool _isValid
 
bool _pixelOwn
 
PixelType _pixelType
 

Detailed Description

Definition at line 32 of file Color.h.

Member Enumeration Documentation

◆ PixelType

enum Magick::Color::PixelType
protected

Definition at line 149 of file Color.h.

150 {
151 RGBPixel,
152 RGBAPixel,
153 CYMKPixel
154 };

Constructor & Destructor Documentation

◆ Color() [1/8]

Magick::Color::Color ( void )

Definition at line 76 of file Color.cpp.

77 : _pixel(new PixelPacket),
78 _isValid(false),
79 _pixelOwn(true),
80 _pixelType(RGBAPixel)
81{
82 initPixel();
83
84 _pixel->opacity=TransparentOpacity;
85}

◆ Color() [2/8]

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

Definition at line 87 of file Color.cpp.

89 : _pixel(new PixelPacket),
90 _isValid(true),
91 _pixelOwn(true),
92 _pixelType(RGBPixel)
93{
94 redQuantum(red_);
95 greenQuantum(green_);
96 blueQuantum(blue_);
97 alphaQuantum(OpaqueOpacity);
98}

◆ Color() [3/8]

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

Definition at line 100 of file Color.cpp.

102 : _pixel(new PixelPacket),
103 _isValid(true),
104 _pixelOwn(true),
105 _pixelType(RGBAPixel)
106{
107 redQuantum(red_);
108 greenQuantum(green_);
109 blueQuantum(blue_);
110 alphaQuantum(alpha_);
111}

◆ Color() [4/8]

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

Definition at line 113 of file Color.cpp.

114 : _pixel(new PixelPacket),
115 _isValid(true),
116 _pixelOwn(true),
117 _pixelType(RGBPixel)
118{
119 initPixel();
120
121 // Use operator = implementation
122 *this=x11color_;
123}

◆ Color() [5/8]

Magick::Color::Color ( const Color & color_)

Definition at line 125 of file Color.cpp.

126 : _pixel(new PixelPacket),
127 _isValid(color_._isValid),
128 _pixelOwn(true),
129 _pixelType(color_._pixelType)
130{
131 *_pixel=*color_._pixel;
132}

◆ Color() [6/8]

Magick::Color::Color ( const PixelPacket & color_)

Definition at line 134 of file Color.cpp.

135 : _pixel(new PixelPacket),
136 _isValid(true),
137 _pixelOwn(true),
138 _pixelType(RGBPixel)
139{
140 *_pixel=color_;
141
142 if (color_.opacity != OpaqueOpacity)
143 _pixelType=RGBAPixel;
144}

◆ Color() [7/8]

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

Definition at line 146 of file Color.cpp.

147 : _pixel(new PixelPacket),
148 _isValid(true),
149 _pixelOwn(true),
150 _pixelType(RGBPixel)
151{
152 initPixel();
153
154 // Use operator = implementation
155 *this=x11color_;
156}

◆ ~Color()

Magick::Color::~Color ( void )
virtual

Definition at line 158 of file Color.cpp.

159{
160 if (_pixelOwn)
161 delete _pixel;
162
163 _pixel=(PixelPacket *)NULL;
164}

◆ Color() [8/8]

Magick::Color::Color ( PixelPacket * rep_,
PixelType pixelType_ )
protected

Definition at line 277 of file Color.cpp.

278 : _pixel(rep_),
279 _isValid(true),
280 _pixelOwn(false),
281 _pixelType(pixelType_)
282{
283}

Member Function Documentation

◆ alpha() [1/2]

void Magick::Color::alpha ( double alpha_)
inline

Definition at line 382 of file Color.h.

383{
384 alphaQuantum(scaleDoubleToQuantum(alpha_));
385}

◆ alpha() [2/2]

double Magick::Color::alpha ( void ) const
inline

Definition at line 386 of file Color.h.

387{
388 return scaleQuantumToDouble(alphaQuantum());
389}

◆ alphaQuantum()

Magick::Quantum Magick::Color::alphaQuantum ( void ) const
inline

Definition at line 397 of file Color.h.

398{
399 return _pixel->opacity;
400}

◆ blueQuantum()

Magick::Quantum Magick::Color::blueQuantum ( void ) const
inline

Definition at line 408 of file Color.h.

409{
410 return _pixel->blue;
411}

◆ greenQuantum()

Magick::Quantum Magick::Color::greenQuantum ( void ) const
inline

Definition at line 419 of file Color.h.

420{
421 return _pixel->green;
422}

◆ initPixel()

void Magick::Color::initPixel ( )
inlineprivate

Definition at line 435 of file Color.h.

436{
437 _pixel->red=0;
438 _pixel->green=0;
439 _pixel->blue=0;
440 _pixel->opacity=TransparentOpacity;
441}

◆ intensity()

double Magick::Color::intensity ( void ) const
inline

Definition at line 108 of file Color.h.

109 {
110 return (0.299*(_pixel->red)+0.587*(_pixel->green)+0.114*(_pixel->blue));
111 }

◆ isValid() [1/2]

void Magick::Color::isValid ( bool valid_)

Definition at line 261 of file Color.cpp.

262{
263 if (bool(valid_) == bool(isValid()))
264 return;
265
266 if (!_pixelOwn)
267 {
268 _pixel=new PixelPacket;
269 _pixelOwn=true;
270 }
271
272 _isValid=valid_;
273
274 initPixel();
275}

◆ isValid() [2/2]

bool Magick::Color::isValid ( void ) const

Definition at line 256 of file Color.cpp.

257{
258 return(_isValid);
259}

◆ operator std::string()

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

Definition at line 233 of file Color.cpp.

234{
235 char
236 colorbuf[MaxTextExtent];
237
238 MagickPixelPacket
239 pixel;
240
241 if (!isValid())
242 return std::string("none");
243
244 pixel.colorspace=sRGBColorspace;
245 pixel.matte=_pixelType == RGBAPixel ? MagickTrue : MagickFalse;
246 pixel.depth=MAGICKCORE_QUANTUM_DEPTH;
247 pixel.red=_pixel->red;
248 pixel.green=_pixel->green;
249 pixel.blue=_pixel->blue;
250 pixel.opacity=_pixel->opacity;
251 GetColorTuple(&pixel,MagickTrue,colorbuf);
252
253 return(std::string(colorbuf));
254}

◆ operator=() [1/3]

const Magick::Color & Magick::Color::operator= ( const char * x11color)

Definition at line 166 of file Color.cpp.

167{
168 *this=std::string(x11color_);
169 return(*this);
170}

◆ operator=() [2/3]

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

Definition at line 172 of file Color.cpp.

173{
174 // If not being set to ourself
175 if (this != &color_)
176 {
177 // Copy pixel value
178 *_pixel=*color_._pixel;
179
180 // Validity
181 _isValid=color_._isValid;
182
183 // Copy pixel type
184 _pixelType=color_._pixelType;
185 }
186 return(*this);
187}

◆ operator=() [3/3]

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

Definition at line 202 of file Color.cpp.

203{
204 PixelPacket
205 target_color;
206
207 initPixel();
208 GetPPException;
209 if (QueryColorDatabase(x11color_.c_str(),&target_color,exceptionInfo))
210 {
211 redQuantum( target_color.red );
212 greenQuantum( target_color.green );
213 blueQuantum( target_color.blue );
214 alphaQuantum( target_color.opacity );
215
216 if (target_color.opacity > OpaqueOpacity)
217 _pixelType=RGBAPixel;
218 else
219 _pixelType=RGBPixel;
220 }
221 else
222 {
223 _isValid = false;
224 _pixelOwn = false;
225 delete _pixel;
226 _pixel = (PixelPacket *)NULL;
227 }
228 ThrowPPException(false);
229
230 return(*this);
231}

◆ pixel()

void Magick::Color::pixel ( PixelPacket * rep_,
PixelType pixelType_ )
protected

Definition at line 285 of file Color.cpp.

286{
287 if (_pixelOwn)
288 delete _pixel;
289
290 _pixel=rep_;
291 _pixelOwn=false;
292 _isValid=true;
293 _pixelType=pixelType_;
294}

◆ redQuantum()

Magick::Quantum Magick::Color::redQuantum ( void ) const
inline

Definition at line 430 of file Color.h.

431{
432 return _pixel->red;
433}

◆ scaleDoubleToQuantum()

static Quantum Magick::Color::scaleDoubleToQuantum ( const double double_)
inlinestatic

Definition at line 114 of file Color.h.

115 {
116 return (static_cast<Magick::Quantum>(double_*QuantumRange));
117 }

◆ scaleQuantumToDouble()

static double Magick::Color::scaleQuantumToDouble ( const Quantum quantum_)
inlinestatic

Definition at line 121 of file Color.h.

122 {
123 return (static_cast<double>(quantum_)/QuantumRange);
124 }

Member Data Documentation

◆ _isValid

bool Magick::Color::_isValid
private

Definition at line 174 of file Color.h.

◆ _pixel

PixelPacket* Magick::Color::_pixel
protected

Definition at line 170 of file Color.h.

◆ _pixelOwn

bool Magick::Color::_pixelOwn
private

Definition at line 175 of file Color.h.

◆ _pixelType

PixelType Magick::Color::_pixelType
private

Definition at line 176 of file Color.h.


The documentation for this class was generated from the following files: