mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Shading: Axial shading (first part)
This commit is contained in:
@@ -30,6 +30,7 @@ namespace pdf
|
||||
class PDFArray;
|
||||
class PDFObject;
|
||||
class PDFStream;
|
||||
class PDFPattern;
|
||||
class PDFDocument;
|
||||
class PDFDictionary;
|
||||
class PDFAbstractColorSpace;
|
||||
@@ -60,6 +61,7 @@ static constexpr const char* COLOR_SPACE_NAME_LAB = "Lab";
|
||||
static constexpr const char* COLOR_SPACE_NAME_ICCBASED = "ICCBased";
|
||||
static constexpr const char* COLOR_SPACE_NAME_INDEXED = "Indexed";
|
||||
static constexpr const char* COLOR_SPACE_NAME_SEPARATION = "Separation";
|
||||
static constexpr const char* COLOR_SPACE_NAME_PATTERN = "Pattern";
|
||||
|
||||
static constexpr const char* CAL_WHITE_POINT = "WhitePoint";
|
||||
static constexpr const char* CAL_BLACK_POINT = "BlackPoint";
|
||||
@@ -209,6 +211,10 @@ public:
|
||||
virtual size_t getColorComponentCount() const = 0;
|
||||
virtual QImage getImage(const PDFImageData& imageData) const;
|
||||
|
||||
/// Checks, if number of color components is OK, and if yes, converts them to the QColor value.
|
||||
/// If they are not OK, exception is thrown.
|
||||
QColor getCheckedColor(const PDFColor& color) const;
|
||||
|
||||
/// Parses the desired color space. If desired color space is not found, then exception is thrown.
|
||||
/// If everything is OK, then shared pointer to the new color space is returned.
|
||||
/// \param colorSpaceDictionary Dictionary containing color spaces of the page
|
||||
@@ -227,6 +233,9 @@ public:
|
||||
const PDFDocument* document,
|
||||
const QByteArray& name);
|
||||
|
||||
/// Converts a vector of real numbers to the PDFColor
|
||||
static PDFColor convertToColor(const std::vector<PDFReal>& components);
|
||||
|
||||
protected:
|
||||
/// Clips the color component to range [0, 1]
|
||||
static constexpr PDFColorComponent clip01(PDFColorComponent component) { return qBound<PDFColorComponent>(0.0, component, 1.0); }
|
||||
@@ -511,8 +520,23 @@ private:
|
||||
PDFFunctionPtr m_tintTransform;
|
||||
};
|
||||
|
||||
class PDFPatternColorSpace : public PDFAbstractColorSpace
|
||||
{
|
||||
public:
|
||||
explicit PDFPatternColorSpace(std::shared_ptr<PDFPattern>&& pattern) : m_pattern(qMove(pattern)) { }
|
||||
virtual ~PDFPatternColorSpace() override = default;
|
||||
|
||||
virtual QColor getDefaultColor() const override;
|
||||
virtual QColor getColor(const PDFColor& color) const override;
|
||||
virtual size_t getColorComponentCount() const override;
|
||||
|
||||
const PDFPattern* getPattern() const { return m_pattern.get(); }
|
||||
|
||||
private:
|
||||
std::shared_ptr<PDFPattern> m_pattern;
|
||||
};
|
||||
|
||||
// TODO: Implement DeviceN color space
|
||||
// TODO: Implement Pattern color space
|
||||
|
||||
} // namespace pdf
|
||||
|
||||
|
Reference in New Issue
Block a user