/usr/include/podofo/base/PdfColor.h is in libpodofo-dev 0.9.4-6.
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 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 | /***************************************************************************
* Copyright (C) 2007 by Dominik Seichter *
* domseichter@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* In addition, as a special exception, the copyright holders give *
* permission to link the code of portions of this program with the *
* OpenSSL library under certain conditions as described in each *
* individual source file, and distribute linked combinations *
* including the two. *
* You must obey the GNU General Public License in all respects *
* for all of the code used other than OpenSSL. If you modify *
* file(s) with this exception, you may extend this exception to your *
* version of the file(s), but you are not obligated to do so. If you *
* do not wish to do so, delete this exception statement from your *
* version. If you delete this exception statement from all source *
* files in the program, then also delete it here. *
***************************************************************************/
#ifndef _PDF_COLOR_H_
#define _PDF_COLOR_H_
#include "PdfDefines.h"
#include "PdfName.h"
namespace PoDoFo {
class PdfArray;
class PdfObject;
class PdfVecObjects;
/** A color object can represent either a grayscale
* value, a RGB color, a CMYK color, a separation color or
* a CieLab color.
*
* All drawing functions in PoDoFo accept a PdfColor object
* to specify a drawing color in one of these colorspaces.
*
* Derived classes PdfColorGray, PdfColorRGB, PdfColorCMYK, PdfColorSeparation
* and PdfColorCieLab are available for easy construction
*/
class PODOFO_API PdfColor {
public:
/** Create a PdfColor object that is RGB black.
*/
PdfColor();
/** Create a new PdfColor object with
* a grayscale value.
*
* \param dGray a grayscalue value between 0.0 and 1.0
*/
explicit PdfColor( double dGray );
/** Create a new PdfColor object with
* a RGB color
*
* \param dRed the value of the red component, must be between 0.0 and 1.0
* \param dGreen the value of the green component, must be between 0.0 and 1.0
* \param dBlue the value of the blue component, must be between 0.0 and 1.0
*/
PdfColor( double dRed, double dGreen, double dBlue );
/** Create a new PdfColor object with
* a CMYK color
*
* \param dCyan the value of the cyan component, must be between 0.0 and 1.0
* \param dMagenta the value of the magenta component, must be between 0.0 and 1.0
* \param dYellow the value of the yellow component, must be between 0.0 and 1.0
* \param dBlack the value of the black component, must be between 0.0 and 1.0
*/
PdfColor( double dCyan, double dMagenta, double dYellow, double dBlack );
/** Copy constructor
*
* \param rhs copy rhs into this object
*/
PdfColor( const PdfColor & rhs );
/** Destructor
*/
virtual ~PdfColor();
/** Assignment operator
*
* \param rhs copy rhs into this object
*
* \returns a reference to this color object
*/
const PdfColor & operator=( const PdfColor & rhs );
/** Test for equality of colors.
*
* \param rhs color to compare ro
*
* \returns true if object color is equal to rhs
*/
inline bool operator==( const PdfColor & rhs ) const;
/** Test for inequality of colors.
*
* \param rhs color to compare ro
*
* \returns true if object color is not equal to rhs
*/
inline bool operator!=( const PdfColor & rhs ) const;
/** Test if this is a grayscale color.
*
* \returns true if this is a grayscale PdfColor object
*/
inline bool IsGrayScale() const;
/** Test if this is a RGB color.
*
* \returns true if this is a RGB PdfColor object
*/
inline bool IsRGB() const;
/** Test if this is a CMYK color.
*
* \returns true if this is a CMYK PdfColor object
*/
inline bool IsCMYK() const;
/** Test if this is a separation color.
*
* \returns true if this is a separation PdfColor object
*/
inline bool IsSeparation() const;
/** Test if this is a CIE-Lab color.
*
* \returns true if this is a lab Color object
*/
inline bool IsCieLab() const;
/** Get the colorspace of this PdfColor object
*
* \returns the colorspace of this PdfColor object
*/
inline EPdfColorSpace GetColorSpace() const;
/** Get the alternate colorspace of this PdfColor object
*
* \returns the colorspace of this PdfColor object (must be separation)
*/
inline EPdfColorSpace GetAlternateColorSpace() const;
/** Get the grayscale color value
* of this object.
*
* Throws an exception if this is no grayscale color object.
*
* \returns the grayscale color value of this object (between 0.0 and 1.0)
*
* \see IsGrayScale
*/
inline double GetGrayScale() const;
/** Get the red color value
* of this object.
*
* Throws an exception if this is no RGB color object.
*
* \returns the red color value of this object (between 0.0 and 1.0)
*
* \see IsRGB
*/
inline double GetRed() const;
/** Get the green color value
* of this object.
*
* Throws an exception if this is no RGB color object.
*
* \returns the green color value of this object (between 0.0 and 1.0)
*
* \see IsRGB
*/
inline double GetGreen() const;
/** Get the blue color value
* of this object.
*
* Throws an exception if this is no RGB color object.
*
* \returns the blue color value of this object (between 0.0 and 1.0)
*
* \see IsRGB
*/
inline double GetBlue() const;
/** Get the cyan color value
* of this object.
*
* Throws an exception if this is no CMYK or separation color object.
*
* \returns the cyan color value of this object (between 0.0 and 1.0)
*
* \see IsCMYK
*/
inline double GetCyan() const;
/** Get the magenta color value
* of this object.
*
* Throws an exception if this is no CMYK or separation color object.
*
* \returns the magenta color value of this object (between 0.0 and 1.0)
*
* \see IsCMYK
*/
inline double GetMagenta() const;
/** Get the yellow color value
* of this object.
*
* Throws an exception if this is no CMYK or separation color object.
*
* \returns the yellow color value of this object (between 0.0 and 1.0)
*
* \see IsCMYK
*/
inline double GetYellow() const;
/** Get the black color value
* of this object.
*
* Throws an exception if this is no CMYK or separation color object.
*
* \returns the black color value of this object (between 0.0 and 1.0)
*
* \see IsCMYK
*/
inline double GetBlack() const;
/** Get the separation name of this object.
*
* Throws an exception if this is no separation color object.
*
* \returns the name of this object
*
* \see IsSeparation
*/
inline const std::string GetName() const;
/** Get the density color value
* of this object.
*
* Throws an exception if this is no separation color object.
*
* \returns the density value of this object (between 0.0 and 1.0)
*
* \see IsSeparation
*/
inline double GetDensity() const;
/** Get the L color value
* of this object.
*
* Throws an exception if this is no CIE-Lab color object.
*
* \returns the L color value of this object (between 0.0 and 100.0)
*
* \see IsCieLab
*/
inline double GetCieL() const;
/** Get the A color value
* of this object.
*
* Throws an exception if this is no CIE-Lab color object.
*
* \returns the A color value of this object (between -128.0 and 127.0)
*
* \see IsCieLab
*/
inline double GetCieA() const;
/** Get the B color value
* of this object.
*
* Throws an exception if this is no CIE-Lab color object.
*
* \returns the B color value of this object (between -128.0 and 127.0)
*
* \see IsCieLab
*/
inline double GetCieB() const;
/** Converts the color object into a grayscale
* color object.
*
* This is only a convinience function. It might be useful
* for on screen display but is in NO WAY suitable to
* professional printing!
*
* \returns a grayscale color object
* \see IsGrayScale()
*/
PdfColor ConvertToGrayScale() const;
/** Converts the color object into a RGB
* color object.
*
* This is only a convinience function. It might be useful
* for on screen display but is in NO WAY suitable to
* professional printing!
*
* \returns a RGB color object
* \see IsRGB()
*/
PdfColor ConvertToRGB() const;
/** Converts the color object into a CMYK
* color object.
*
* This is only a convinience function. It might be useful
* for on screen display but is in NO WAY suitable to
* professional printing!
*
* \returns a CMYK color object
* \see IsCMYK()
*/
PdfColor ConvertToCMYK() const;
/** Creates a PdfArray which represents a color from a color.
* \returns a PdfArray object
*/
PdfArray ToArray() const;
/** Creates a color object from a string.
*
* \param pszName a string describing a color.
*
* Supported values are:
* - single gray values as string (e.g. '0.5')
* - a named color (e.g. 'auquamarine' or 'magenta')
* - hex values (e.g. #FF002A (RGB) or #FF12AB3D (CMYK))
* - PdfArray's
*
* \returns a PdfColor object
*/
static PdfColor FromString( const char* pszName );
/** Creates a color object from a PdfArray which represents a color.
*
* Raises an exception if this is no PdfColor!
*
* \param rArray an array that must be a color PdfArray
* \returns a PdfColor object
*/
static PdfColor FromArray( const PdfArray & rArray );
/**
* Convert a name into a colorspace enum.
* @param rName name representing a colorspace such as DeviceGray
* @returns colorspace enum or ePdfColorSpace_Unknown if name is unknown
* @see GetNameForColorSpace
*/
static EPdfColorSpace GetColorSpaceForName( const PdfName & rName );
/**
* Convert a colorspace enum value into a name such as DeviceRGB
* @param eColorSpace a colorspace
* @returns a name
* @see GetColorSpaceForName
*/
static PdfName GetNameForColorSpace( EPdfColorSpace eColorSpace );
/** Creates a colorspace object from a color to insert into resources.
*
* \param pOwner a pointer to the owner of the generated object
* \returns a PdfObject pointer, which can be insert into resources, NULL if not needed
*/
PdfObject* BuildColorSpace( PdfVecObjects* pOwner ) const;
protected:
union {
double cmyk[4];
double rgb[3];
double lab[3];
double gray;
} m_uColor;
std::string m_separationName;
double m_separationDensity;
EPdfColorSpace m_eColorSpace;
EPdfColorSpace m_eAlternateColorSpace;
private:
static const unsigned int* const m_hexDigitMap; ///< Mapping of hex sequences to int value
};
class PODOFO_API PdfColorGray : public PdfColor {
public:
/** Create a new PdfColor object with
* a grayscale value.
*
* \param dGray a grayscalue value between 0.0 and 1.0
*/
explicit PdfColorGray( double dGray );
/** Class destructor.
*/
virtual ~PdfColorGray();
private:
/** Default constructor, not implemented
*/
PdfColorGray();
/** Copy constructor, not implemented
*/
PdfColorGray(const PdfColorGray& );
/** Copy assignment operator, not implemented
*/
PdfColorGray& operator=(const PdfColorGray&);
};
class PODOFO_API PdfColorRGB : public PdfColor {
public:
/** Create a new PdfColor object with
* a RGB color
*
* \param dRed the value of the red component, must be between 0.0 and 1.0
* \param dGreen the value of the green component, must be between 0.0 and 1.0
* \param dBlue the value of the blue component, must be between 0.0 and 1.0
*/
PdfColorRGB( double dRed, double dGreen, double dBlue );
/** Class destructor.
*/
virtual ~PdfColorRGB();
private:
/** Default constructor, not implemented
*/
PdfColorRGB();
/** Copy constructor, not implemented
*/
PdfColorRGB(const PdfColorRGB& );
/** Copy assignment operator, not implemented
*/
PdfColorRGB& operator=(const PdfColorRGB&);
};
class PODOFO_API PdfColorCMYK : public PdfColor {
public:
/** Create a new PdfColor object with
* a CMYK color
*
* \param dCyan the value of the cyan component, must be between 0.0 and 1.0
* \param dMagenta the value of the magenta component, must be between 0.0 and 1.0
* \param dYellow the value of the yellow component, must be between 0.0 and 1.0
* \param dBlack the value of the black component, must be between 0.0 and 1.0
*/
PdfColorCMYK( double dCyan, double dMagenta, double dYellow, double dBlack );
/** Class destructor.
*/
virtual ~PdfColorCMYK();
private:
/** Default constructor, not implemented
*/
PdfColorCMYK();
/** Copy constructor, not implemented
*/
PdfColorCMYK(const PdfColorCMYK& );
/** Copy assignment operator, not implemented
*/
PdfColorCMYK& operator=(const PdfColorCMYK&);
};
class PODOFO_API PdfColorSeparationAll : public PdfColor {
public:
/** Create a new PdfColor object with
* Separation color All.
*
*/
PdfColorSeparationAll();
/** Class destructor.
*/
virtual ~PdfColorSeparationAll();
private:
/** Copy constructor, not implemented
*/
PdfColorSeparationAll(const PdfColorSeparationAll& );
/** Copy assignment operator, not implemented
*/
PdfColorSeparationAll& operator=(const PdfColorSeparationAll&);
};
class PODOFO_API PdfColorSeparationNone : public PdfColor {
public:
/** Create a new PdfColor object with
* Separation color None.
*
*/
PdfColorSeparationNone();
/** Class destructor.
*/
virtual ~PdfColorSeparationNone();
private:
/** Copy constructor, not implemented
*/
PdfColorSeparationNone(const PdfColorSeparationNone& );
/** Copy assignment operator, not implemented
*/
PdfColorSeparationNone& operator=(const PdfColorSeparationNone&);
};
class PODOFO_API PdfColorSeparation : public PdfColor {
public:
/** Create a new PdfColor object with
* a separation-name and an equivalent color
*
* \param sName Name of the separation color
* \param sDensity the density value of the separation color
* \param alternateColor the alternate color, must be of typ gray, rgb, cmyk or cie
*/
PdfColorSeparation( const std::string & sName, double dDensity, const PdfColor & alternateColor );
/** Class destructor.
*/
virtual ~PdfColorSeparation();
private:
/** Default constructor, not implemented
*/
PdfColorSeparation();
/** Copy constructor, not implemented
*/
PdfColorSeparation(const PdfColorSeparation& );
/** Copy assignment operator, not implemented
*/
PdfColorSeparation& operator=(const PdfColorSeparation&);
};
class PODOFO_API PdfColorCieLab : public PdfColor {
public:
/** Create a new PdfColor object with
* a CIE-LAB-values
*
* \param dCieL the value of the L component, must be between 0.0 and 100.0
* \param dCieA the value of the A component, must be between -128.0 and 127.0
* \param dCieB the value of the B component, must be between -128.0 and 127.0
*/
PdfColorCieLab( double dCieL, double dCieA, double dCieB );
/** Class destructor.
*/
virtual ~PdfColorCieLab();
private:
/** Default constructor, not implemented
*/
PdfColorCieLab();
/** Copy constructor, not implemented
*/
PdfColorCieLab(const PdfColorCieLab& );
/** Copy assignment operator, not implemented
*/
PdfColorCieLab& operator=(const PdfColorCieLab&);
};
// -----------------------------------------------------
//
// -----------------------------------------------------
inline bool PdfColor::operator==( const PdfColor & rhs ) const
{
if ( m_eColorSpace == rhs.m_eColorSpace )
{
if (
(m_eColorSpace == ePdfColorSpace_DeviceGray) &&
(m_uColor.gray == rhs.m_uColor.gray)
)
return true;
if (
(m_eColorSpace == ePdfColorSpace_DeviceRGB) &&
(m_uColor.rgb[0] == rhs.m_uColor.rgb[0]) &&
(m_uColor.rgb[1] == rhs.m_uColor.rgb[1]) &&
(m_uColor.rgb[2] == rhs.m_uColor.rgb[2])
)
return true;
if (
(m_eColorSpace == ePdfColorSpace_DeviceCMYK) &&
(m_uColor.cmyk[0] == rhs.m_uColor.cmyk[0]) &&
(m_uColor.cmyk[1] == rhs.m_uColor.cmyk[1]) &&
(m_uColor.cmyk[2] == rhs.m_uColor.cmyk[2]) &&
(m_uColor.cmyk[3] == rhs.m_uColor.cmyk[3])
)
return true;
if (
(m_eColorSpace == ePdfColorSpace_CieLab) &&
(m_uColor.lab[0] == rhs.m_uColor.lab[0]) &&
(m_uColor.lab[1] == rhs.m_uColor.lab[1]) &&
(m_uColor.lab[2] == rhs.m_uColor.lab[2])
)
return true;
if (
(m_eColorSpace == ePdfColorSpace_Separation) &&
(m_separationDensity == rhs.m_separationDensity) &&
(m_separationName == rhs.m_separationName) &&
(m_eAlternateColorSpace == rhs.m_eAlternateColorSpace) &&
(
(
(m_eAlternateColorSpace == ePdfColorSpace_DeviceGray) &&
(m_uColor.gray == rhs.m_uColor.gray)
) ||
(
(m_eAlternateColorSpace == ePdfColorSpace_DeviceRGB) &&
(m_uColor.rgb[0] == rhs.m_uColor.rgb[0]) &&
(m_uColor.rgb[1] == rhs.m_uColor.rgb[1]) &&
(m_uColor.rgb[2] == rhs.m_uColor.rgb[2])
) ||
(
(m_eAlternateColorSpace == ePdfColorSpace_DeviceCMYK) &&
(m_uColor.cmyk[0] == rhs.m_uColor.cmyk[0]) &&
(m_uColor.cmyk[1] == rhs.m_uColor.cmyk[1]) &&
(m_uColor.cmyk[2] == rhs.m_uColor.cmyk[2]) &&
(m_uColor.cmyk[3] == rhs.m_uColor.cmyk[3])
) ||
(
(m_eAlternateColorSpace == ePdfColorSpace_CieLab) &&
(m_uColor.lab[0] == rhs.m_uColor.lab[0]) &&
(m_uColor.lab[1] == rhs.m_uColor.lab[1]) &&
(m_uColor.lab[2] == rhs.m_uColor.lab[2])
)
)
)
return true;
if (m_eColorSpace == ePdfColorSpace_Unknown)
return true;
}
return false;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
inline bool PdfColor::operator!=( const PdfColor & rhs ) const
{
return ! (*this == rhs);
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfColor::IsGrayScale() const
{
return (m_eColorSpace == ePdfColorSpace_DeviceGray);
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfColor::IsRGB() const
{
return (m_eColorSpace == ePdfColorSpace_DeviceRGB);
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfColor::IsCMYK() const
{
return (m_eColorSpace == ePdfColorSpace_DeviceCMYK);
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfColor::IsSeparation() const
{
return (m_eColorSpace == ePdfColorSpace_Separation);
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfColor::IsCieLab() const
{
return (m_eColorSpace == ePdfColorSpace_CieLab);
}
// -----------------------------------------------------
//
// -----------------------------------------------------
EPdfColorSpace PdfColor::GetColorSpace() const
{
return m_eColorSpace;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
EPdfColorSpace PdfColor::GetAlternateColorSpace() const
{
PODOFO_RAISE_LOGIC_IF( !this->IsSeparation(), "PdfColor::GetAlternateColorSpace cannot be called on non separation color objects!");
return m_eAlternateColorSpace;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
double PdfColor::GetGrayScale() const
{
PODOFO_RAISE_LOGIC_IF( !this->IsGrayScale() &&
!(this->IsSeparation() && (this->m_eAlternateColorSpace == ePdfColorSpace_DeviceGray)),
"PdfColor::GetGrayScale cannot be called on non grayscale color objects!");
return m_uColor.gray;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
double PdfColor::GetRed() const
{
PODOFO_RAISE_LOGIC_IF( !this->IsRGB() &&
!(this->IsSeparation() && (this->m_eAlternateColorSpace == ePdfColorSpace_DeviceRGB)),
"PdfColor::GetRed cannot be called on non RGB color objects!");
return m_uColor.rgb[0];
}
// -----------------------------------------------------
//
// -----------------------------------------------------
double PdfColor::GetGreen() const
{
PODOFO_RAISE_LOGIC_IF( !this->IsRGB() &&
!(this->IsSeparation() && (this->m_eAlternateColorSpace == ePdfColorSpace_DeviceRGB)),
"PdfColor::GetGreen cannot be called on non RGB color objects!");
return m_uColor.rgb[1];
}
// -----------------------------------------------------
//
// -----------------------------------------------------
double PdfColor::GetBlue() const
{
PODOFO_RAISE_LOGIC_IF( !this->IsRGB() &&
!(this->IsSeparation() && (this->m_eAlternateColorSpace == ePdfColorSpace_DeviceRGB)),
"PdfColor::GetBlue cannot be called on non RGB color objects!");
return m_uColor.rgb[2];
}
// -----------------------------------------------------
//
// -----------------------------------------------------
double PdfColor::GetCyan() const
{
PODOFO_RAISE_LOGIC_IF( !this->IsCMYK() &&
!(this->IsSeparation() && (this->m_eAlternateColorSpace == ePdfColorSpace_DeviceCMYK)),
"PdfColor::GetCyan cannot be called on non CMYK color objects!");
return m_uColor.cmyk[0];
}
// -----------------------------------------------------
//
// -----------------------------------------------------
double PdfColor::GetMagenta() const
{
PODOFO_RAISE_LOGIC_IF( !this->IsCMYK() &&
!(this->IsSeparation() && (this->m_eAlternateColorSpace == ePdfColorSpace_DeviceCMYK)),
"PdfColor::GetMagenta cannot be called on non CMYK color objects!");
return m_uColor.cmyk[1];
}
// -----------------------------------------------------
//
// -----------------------------------------------------
double PdfColor::GetYellow() const
{
PODOFO_RAISE_LOGIC_IF( !this->IsCMYK() &&
!(this->IsSeparation() && (this->m_eAlternateColorSpace == ePdfColorSpace_DeviceCMYK)),
"PdfColor::GetYellow cannot be called on non CMYK color objects!");
return m_uColor.cmyk[2];
}
// -----------------------------------------------------
//
// -----------------------------------------------------
double PdfColor::GetBlack() const
{
PODOFO_RAISE_LOGIC_IF( !this->IsCMYK() &&
!(this->IsSeparation() && (this->m_eAlternateColorSpace == ePdfColorSpace_DeviceCMYK)),
"PdfColor::GetBlack cannot be called on non CMYK color objects!");
return m_uColor.cmyk[3];
}
// -----------------------------------------------------
//
// -----------------------------------------------------
const std::string PdfColor::GetName() const
{
PODOFO_RAISE_LOGIC_IF( !this->IsSeparation(), "PdfColor::GetName cannot be called on non separation color objects!");
return m_separationName;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
double PdfColor::GetDensity() const
{
PODOFO_RAISE_LOGIC_IF( !this->IsSeparation(), "PdfColor::GetDensity cannot be called on non separation color objects!");
return m_separationDensity;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
double PdfColor::GetCieL() const
{
PODOFO_RAISE_LOGIC_IF( !this->IsCieLab() &&
!(this->IsSeparation() && (this->m_eAlternateColorSpace == ePdfColorSpace_CieLab)),
"PdfColor::GetCieL cannot be called on non CIE-Lab color objects!");
return m_uColor.lab[0];
}
// -----------------------------------------------------
//
// -----------------------------------------------------
double PdfColor::GetCieA() const
{
PODOFO_RAISE_LOGIC_IF( !this->IsCieLab() &&
!(this->IsSeparation() && (this->m_eAlternateColorSpace == ePdfColorSpace_CieLab)),
"PdfColor::GetCieA cannot be called on non CIE-Lab color objects!");
return m_uColor.lab[1];
}
// -----------------------------------------------------
//
// -----------------------------------------------------
double PdfColor::GetCieB() const
{
PODOFO_RAISE_LOGIC_IF( !this->IsCieLab() &&
!(this->IsSeparation() && (this->m_eAlternateColorSpace == ePdfColorSpace_CieLab)),
"PdfColor::GetCieB cannot be called on non CIE-Lab color objects!");
return m_uColor.lab[2];
}
};
#endif // _PDF_COLOR_H_
|