/usr/include/ImageMagick/Magick++/Color.h is in libmagick++-dev 8:6.7.7.10-6ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | // This may look like C code, but it is really -*- C++ -*-
//
// Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003, 2008
//
// Color Implementation
//
#if !defined (Magick_Color_header)
#define Magick_Color_header
#include "Magick++/Include.h"
#include <string>
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_ );
// Base color class stores RGB components scaled to fit Quantum
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;
// Green color (range 0 to QuantumRange)
void greenQuantum ( Quantum green_ );
Quantum greenQuantum ( void ) const;
// Blue color (range 0 to QuantumRange)
void blueQuantum ( Quantum blue_ );
Quantum blueQuantum ( void ) const;
// Alpha level (range OpaqueOpacity=0 to TransparentOpacity=QuantumRange)
void alphaQuantum ( Quantum alpha_ );
Quantum alphaQuantum ( void ) const;
// 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_ );
// Assignment operator
Color& operator= ( const Color& color_ );
// Return X11 color specification string
/* virtual */ operator std::string() const;
// Return ImageMagick PixelPacket
operator PixelPacket() const;
// Construct color via ImageMagick PixelPacket
Color ( const PixelPacket &color_ );
// Set color via ImageMagick PixelPacket
const Color& operator= ( const PixelPacket &color_ );
//
// Public methods beyond this point are for Magick++ use only.
//
// Obtain pixel intensity as a double
double intensity ( void ) const
{
return (0.299*(_pixel->red)+0.587*(_pixel->green)+0.114*(_pixel->blue));
}
// 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));
}
// 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);
}
protected:
// PixelType specifies the interpretation of PixelPacket members
// RGBPixel:
// Red = red;
// Green = green;
// Blue = blue;
// RGBAPixel:
// Red = red;
// Green = green;
// Blue = blue;
// Alpha = opacity;
// CYMKPixel:
// Cyan = red
// Yellow = green
// Magenta = blue
// Black(K) = opacity
enum PixelType
{
RGBPixel,
RGBAPixel,
CYMKPixel
};
// Constructor to construct with PixelPacket*
// Used to point Color at a pixel in an image
Color ( PixelPacket* rep_, PixelType pixelType_ );
// Set pixel
// Used to point Color at a pixel in an image
void pixel ( PixelPacket* rep_, PixelType pixelType_ );
// PixelPacket represents a color pixel:
// red = red (range 0 to QuantumRange)
// green = green (range 0 to QuantumRange)
// blue = blue (range 0 to QuantumRange)
// opacity = alpha (range OpaqueOpacity=0 to TransparentOpacity=QuantumRange)
// index = PseudoColor colormap index
PixelPacket* _pixel;
private:
// Common initializer for PixelPacket 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 PixelPacket*
ColorHSL ( PixelPacket* 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
{
public:
ColorGray ( double shade_ );
ColorGray ( void );
ColorGray ( const Color & color_ );
/* virtual */ ~ColorGray ();
void shade ( double shade_ );
double shade ( void ) const;
// Assignment operator from base class
ColorGray& operator= ( const Color& color_ );
protected:
// Constructor to construct with PixelPacket*
ColorGray ( PixelPacket* rep_, PixelType pixelType_ );
};
//
// Monochrome color
//
// Color arguments are constrained to 'false' (black pixel) and 'true'
// (white pixel)
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;
// Assignment operator from base class
ColorMono& operator= ( const Color& color_ );
protected:
// Constructor to construct with PixelPacket*
ColorMono ( PixelPacket* rep_, PixelType pixelType_ );
};
//
// RGB color
//
// All color arguments have a valid range of 0.0 - 1.0.
class MagickPPExport ColorRGB : 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;
// Assignment operator from base class
ColorRGB& operator= ( const Color& color_ );
protected:
// Constructor to construct with PixelPacket*
ColorRGB ( PixelPacket* rep_, PixelType pixelType_ );
};
//
// YUV Colorspace color
//
// Argument ranges:
// Y: 0.0 through 1.0
// U: -0.5 through 0.5
// V: -0.5 through 0.5
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;
// Assignment operator from base class
ColorYUV& operator= ( const Color& color_ );
protected:
// Constructor to construct with PixelPacket*
ColorYUV ( PixelPacket* rep_, PixelType pixelType_ );
};
} // namespace Magick
//
// Inlines
//
//
// Color
//
// Common initializer for PixelPacket representation
// Initialized transparent black
inline void Magick::Color::initPixel()
{
_pixel->red = 0;
_pixel->green = 0;
_pixel->blue = 0;
_pixel->opacity = TransparentOpacity;
}
inline void Magick::Color::redQuantum ( Magick::Quantum red_ )
{
_pixel->red = red_;
_isValid = true;
}
inline Magick::Quantum Magick::Color::redQuantum ( void ) const
{
return _pixel->red;
}
inline void Magick::Color::greenQuantum ( Magick::Quantum green_ )
{
_pixel->green = green_;
_isValid = true;
}
inline Magick::Quantum Magick::Color::greenQuantum ( void ) const
{
return _pixel->green;
}
inline void Magick::Color::blueQuantum ( Magick::Quantum blue_ )
{
_pixel->blue = blue_;
_isValid = true;
}
inline Magick::Quantum Magick::Color::blueQuantum ( void ) const
{
return _pixel->blue;
}
inline void Magick::Color::alphaQuantum ( Magick::Quantum alpha_ )
{
_pixel->opacity = alpha_;
_isValid = true ;
}
inline Magick::Quantum Magick::Color::alphaQuantum ( void ) const
{
return _pixel->opacity;
}
// Return ImageMagick PixelPacket struct based on color.
inline Magick::Color::operator MagickCore::PixelPacket () 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::PixelPacket* rep_,
Magick::Color::PixelType pixelType_ )
: Color( rep_, pixelType_ )
{
}
//
// ColorGray
//
inline Magick::ColorGray::ColorGray ( Magick::PixelPacket* rep_,
Magick::Color::PixelType pixelType_ )
: Color( rep_, pixelType_ )
{
}
//
// ColorMono
//
inline Magick::ColorMono::ColorMono ( Magick::PixelPacket* rep_,
Magick::Color::PixelType pixelType_ )
: Color( rep_, pixelType_ )
{
}
//
// ColorRGB
//
inline Magick::ColorRGB::ColorRGB ( Magick::PixelPacket* 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::PixelPacket* rep_,
Magick::Color::PixelType pixelType_ )
: Color( rep_, pixelType_ )
{
}
#endif // Magick_Color_header
|