PoDoFo 1.0.0-dev
Loading...
Searching...
No Matches
PdfColor.h
1
6#ifndef PDF_COLOR_H
7#define PDF_COLOR_H
8
9#include "PdfName.h"
10#include "PdfArray.h"
11
12namespace PoDoFo {
13
14using PdfColorRaw = std::array<double, 6>;
15
22class PODOFO_API PdfColor final
23{
24public:
27 PdfColor();
28
34 explicit PdfColor(double gray);
35
43 PdfColor(double red, double green, double blue);
44
53 PdfColor(double cyan, double magenta, double yellow, double black);
54
59 PdfColor(const PdfColor& rhs) = default;
60
61public:
66 static bool TryCreateFromObject(const PdfObject& obj, PdfColor& color);
67 static PdfColor CreateFromObject(const PdfObject& obj);
68
69 static PdfColor CreateTransparent();
70
71public:
76 bool IsGrayScale() const;
77
82 bool IsRGB() const;
83
88 bool IsCMYK() const;
89
90 bool IsTransparent() const;
91
96 inline PdfColorSpaceType GetColorSpace() const { return m_ColorSpace; }
97
107 double GetGrayScale() const;
108
118 double GetRed() const;
119
129 double GetGreen() const;
130
140 double GetBlue() const;
141
151 double GetCyan() const;
152
162 double GetMagenta() const;
163
173 double GetYellow() const;
174
184 double GetBlack() const;
185
196 PdfColor ConvertToGrayScale() const;
197
208 PdfColor ConvertToRGB() const;
209
220 PdfColor ConvertToCMYK() const;
221
225 PdfArray ToArray() const;
226
239 static PdfColor CreateFromString(const std::string_view& name);
240
241public:
242 unsigned char GetComponentCount() const { return m_ComponentCount; }
243
244 const PdfColorRaw& GetRawColor() const { return m_RawColor; }
245
252 PdfColor& operator=(const PdfColor& rhs) = default;
253
260 bool operator==(const PdfColor& rhs) const;
261
268 bool operator!=(const PdfColor& rhs) const;
269
270private:
271 PdfColor(bool isTransparent, PdfColorSpaceType colorSpace, unsigned char componentCount, const PdfColorRaw& data);
272
273 static bool tryCreateFromArray(const PdfArray& arr, PdfColor& color);
274
275private:
276 bool m_IsTransparent;
277 PdfColorSpaceType m_ColorSpace;
278 unsigned char m_ComponentCount;
279 PdfColorRaw m_RawColor;
280};
281
282};
283
284#endif // PDF_COLOR_H
This class represents a PdfArray Use it for all arrays that are written to a PDF file.
Definition PdfArray.h:81
A color object can represent either a grayscale value, a RGB color, a CMYK color.
Definition PdfColor.h:23
PdfColor & operator=(const PdfColor &rhs)=default
Assignment operator.
PdfColor(const PdfColor &rhs)=default
Copy constructor.
PdfColorSpaceType GetColorSpace() const
Get the colorspace of this PdfColor object.
Definition PdfColor.h:96
This class represents a PDF indirect Object in memory.
Definition PdfObject.h:35
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition basetypes.h:38
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition basetypes.h:16
PdfColorSpaceType
Enum for the colorspaces supported by PDF.
Definition PdfDeclarations.h:359