mirror of https://github.com/JakubMelka/PDF4QT.git
Refactoring of colors, introducing original color
This commit is contained in:
parent
3a2fa64ac0
commit
975bdba6f6
|
@ -68,9 +68,9 @@ PDFColorComponentMatrix_3x3 getInverseMatrix(const PDFColorComponentMatrix_3x3&
|
|||
return inversedMatrix;
|
||||
}
|
||||
|
||||
QColor PDFDeviceGrayColorSpace::getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const
|
||||
PDFColor PDFDeviceGrayColorSpace::getDefaultColorOriginal() const
|
||||
{
|
||||
return getColor(PDFColor(0.0f), cms, intent, reporter, true);
|
||||
return PDFColor(0.0f);
|
||||
}
|
||||
|
||||
QColor PDFDeviceGrayColorSpace::getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const
|
||||
|
@ -107,9 +107,9 @@ void PDFDeviceGrayColorSpace::fillRGBBuffer(const std::vector<float>& colors, un
|
|||
}
|
||||
}
|
||||
|
||||
QColor PDFDeviceRGBColorSpace::getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const
|
||||
PDFColor PDFDeviceRGBColorSpace::getDefaultColorOriginal() const
|
||||
{
|
||||
return getColor(PDFColor(0.0f, 0.0f, 0.0f), cms, intent, reporter, true);
|
||||
return PDFColor(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
QColor PDFDeviceRGBColorSpace::getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const
|
||||
|
@ -146,9 +146,9 @@ void PDFDeviceRGBColorSpace::fillRGBBuffer(const std::vector<float>& colors, uns
|
|||
}
|
||||
}
|
||||
|
||||
QColor PDFDeviceCMYKColorSpace::getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const
|
||||
PDFColor PDFDeviceCMYKColorSpace::getDefaultColorOriginal() const
|
||||
{
|
||||
return getColor(PDFColor(0.0f, 0.0f, 0.0f, 1.0f), cms, intent, reporter, true);
|
||||
return PDFColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
QColor PDFDeviceCMYKColorSpace::getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const
|
||||
|
@ -208,6 +208,11 @@ bool PDFAbstractColorSpace::isBlendColorSpace() const
|
|||
}
|
||||
}
|
||||
|
||||
QColor PDFAbstractColorSpace::getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const
|
||||
{
|
||||
return getColor(getDefaultColorOriginal(), cms, intent, reporter, true);
|
||||
}
|
||||
|
||||
QImage PDFAbstractColorSpace::getImage(const PDFImageData& imageData,
|
||||
const PDFImageData& softMask,
|
||||
const PDFCMS* cms,
|
||||
|
@ -1201,7 +1206,7 @@ PDFColor3 PDFAbstractColorSpace::convertXYZtoRGB(const PDFColor3& xyzColor)
|
|||
return matrixXYZtoRGB * xyzColor;
|
||||
}
|
||||
|
||||
QColor PDFXYZColorSpace::getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const
|
||||
PDFColor PDFXYZColorSpace::getDefaultColorOriginal() const
|
||||
{
|
||||
PDFColor color;
|
||||
const size_t componentCount = getColorComponentCount();
|
||||
|
@ -1209,7 +1214,7 @@ QColor PDFXYZColorSpace::getDefaultColor(const PDFCMS* cms, RenderingIntent inte
|
|||
{
|
||||
color.push_back(0.0f);
|
||||
}
|
||||
return getColor(color, cms, intent, reporter, true);
|
||||
return color;
|
||||
}
|
||||
|
||||
bool PDFXYZColorSpace::equals(const PDFAbstractColorSpace* other) const
|
||||
|
@ -1616,7 +1621,7 @@ PDFICCBasedColorSpace::PDFICCBasedColorSpace(PDFColorSpacePointer alternateColor
|
|||
m_iccProfileDataChecksum = QCryptographicHash::hash(m_iccProfileData, QCryptographicHash::Md5);
|
||||
}
|
||||
|
||||
QColor PDFICCBasedColorSpace::getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const
|
||||
PDFColor PDFICCBasedColorSpace::getDefaultColorOriginal() const
|
||||
{
|
||||
PDFColor color;
|
||||
const size_t componentCount = getColorComponentCount();
|
||||
|
@ -1624,7 +1629,7 @@ QColor PDFICCBasedColorSpace::getDefaultColor(const PDFCMS* cms, RenderingIntent
|
|||
{
|
||||
color.push_back(0.0f);
|
||||
}
|
||||
return getColor(color, cms, intent, reporter, true);
|
||||
return color;
|
||||
}
|
||||
|
||||
QColor PDFICCBasedColorSpace::getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const
|
||||
|
@ -1826,9 +1831,9 @@ bool PDFIndexedColorSpace::equals(const PDFAbstractColorSpace* other) const
|
|||
return m_colors == typedOther->getColors() && m_maxValue == typedOther->getMaxValue();
|
||||
}
|
||||
|
||||
QColor PDFIndexedColorSpace::getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const
|
||||
PDFColor PDFIndexedColorSpace::getDefaultColorOriginal() const
|
||||
{
|
||||
return getColor(PDFColor(0.0f), cms, intent, reporter, true);
|
||||
return PDFColor(0.0f);
|
||||
}
|
||||
|
||||
QColor PDFIndexedColorSpace::getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const
|
||||
|
@ -2093,9 +2098,9 @@ bool PDFSeparationColorSpace::equals(const PDFAbstractColorSpace* other) const
|
|||
return m_colorName == typedOther->getColorName();
|
||||
}
|
||||
|
||||
QColor PDFSeparationColorSpace::getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const
|
||||
PDFColor PDFSeparationColorSpace::getDefaultColorOriginal() const
|
||||
{
|
||||
return getColor(PDFColor(1.0f), cms, intent, reporter, true);
|
||||
return PDFColor(1.0f);
|
||||
}
|
||||
|
||||
QColor PDFSeparationColorSpace::getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const
|
||||
|
@ -2245,6 +2250,11 @@ QColor PDFPatternColorSpace::getDefaultColor(const PDFCMS* cms, RenderingIntent
|
|||
return QColor(Qt::transparent);
|
||||
}
|
||||
|
||||
PDFColor PDFPatternColorSpace::getDefaultColorOriginal() const
|
||||
{
|
||||
return PDFColor();
|
||||
}
|
||||
|
||||
QColor PDFPatternColorSpace::getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const
|
||||
{
|
||||
Q_UNUSED(color);
|
||||
|
@ -2320,7 +2330,7 @@ bool PDFDeviceNColorSpace::equals(const PDFAbstractColorSpace* other) const
|
|||
return true;
|
||||
}
|
||||
|
||||
QColor PDFDeviceNColorSpace::getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const
|
||||
PDFColor PDFDeviceNColorSpace::getDefaultColorOriginal() const
|
||||
{
|
||||
PDFColor color;
|
||||
color.resize(getColorComponentCount());
|
||||
|
@ -2332,7 +2342,7 @@ QColor PDFDeviceNColorSpace::getDefaultColor(const PDFCMS* cms, RenderingIntent
|
|||
color[i] = 1.0;
|
||||
}
|
||||
|
||||
return getColor(color, cms, intent, reporter, true);
|
||||
return color;
|
||||
}
|
||||
|
||||
QColor PDFDeviceNColorSpace::getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const
|
||||
|
|
|
@ -284,7 +284,10 @@ public:
|
|||
bool isBlendColorSpace() const;
|
||||
|
||||
/// Returns default color for the color space
|
||||
virtual QColor getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const = 0;
|
||||
virtual QColor getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const;
|
||||
|
||||
/// Returns default color in original color space (not transformed to QColor)
|
||||
virtual PDFColor getDefaultColorOriginal() const = 0;
|
||||
|
||||
/// Returns transformed color for given input color. Color is transformed using color
|
||||
/// management system (cms), if color management system fails, and returns invalid color,
|
||||
|
@ -501,7 +504,7 @@ public:
|
|||
virtual ~PDFDeviceGrayColorSpace() = default;
|
||||
|
||||
virtual ColorSpace getColorSpace() const override { return ColorSpace::DeviceGray; }
|
||||
virtual QColor getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const override;
|
||||
virtual PDFColor getDefaultColorOriginal() const override;
|
||||
virtual QColor getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const override;
|
||||
virtual size_t getColorComponentCount() const override;
|
||||
virtual void fillRGBBuffer(const std::vector<float>& colors,unsigned char* outputBuffer, RenderingIntent intent, const PDFCMS* cms, PDFRenderErrorReporter* reporter) const override;
|
||||
|
@ -514,7 +517,7 @@ public:
|
|||
virtual ~PDFDeviceRGBColorSpace() = default;
|
||||
|
||||
virtual ColorSpace getColorSpace() const override { return ColorSpace::DeviceRGB; }
|
||||
virtual QColor getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const override;
|
||||
virtual PDFColor getDefaultColorOriginal() const override;
|
||||
virtual QColor getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const override;
|
||||
virtual size_t getColorComponentCount() const override;
|
||||
virtual void fillRGBBuffer(const std::vector<float>& colors,unsigned char* outputBuffer, RenderingIntent intent, const PDFCMS* cms, PDFRenderErrorReporter* reporter) const override;
|
||||
|
@ -527,7 +530,7 @@ public:
|
|||
virtual ~PDFDeviceCMYKColorSpace() = default;
|
||||
|
||||
virtual ColorSpace getColorSpace() const override { return ColorSpace::DeviceCMYK; }
|
||||
virtual QColor getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const override;
|
||||
virtual PDFColor getDefaultColorOriginal() const override;
|
||||
virtual QColor getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const override;
|
||||
virtual size_t getColorComponentCount() const override;
|
||||
virtual void fillRGBBuffer(const std::vector<float>& colors,unsigned char* outputBuffer, RenderingIntent intent, const PDFCMS* cms, PDFRenderErrorReporter* reporter) const override;
|
||||
|
@ -536,8 +539,7 @@ public:
|
|||
class PDFXYZColorSpace : public PDFAbstractColorSpace
|
||||
{
|
||||
public:
|
||||
virtual QColor getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const override;
|
||||
|
||||
virtual PDFColor getDefaultColorOriginal() const override;
|
||||
virtual bool equals(const PDFAbstractColorSpace* other) const override;
|
||||
|
||||
const PDFColor3& getWhitePoint() const { return m_whitePoint; }
|
||||
|
@ -650,7 +652,7 @@ public:
|
|||
virtual ~PDFICCBasedColorSpace() = default;
|
||||
|
||||
virtual ColorSpace getColorSpace() const override { return ColorSpace::ICCBased; }
|
||||
virtual QColor getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const override;
|
||||
virtual PDFColor getDefaultColorOriginal() const override;
|
||||
virtual QColor getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const override;
|
||||
virtual size_t getColorComponentCount() const override;
|
||||
virtual void fillRGBBuffer(const std::vector<float>& colors, unsigned char* outputBuffer, RenderingIntent intent, const PDFCMS* cms, PDFRenderErrorReporter* reporter) const override;
|
||||
|
@ -691,7 +693,7 @@ public:
|
|||
|
||||
virtual ColorSpace getColorSpace() const override { return ColorSpace::Indexed; }
|
||||
virtual bool equals(const PDFAbstractColorSpace* other) const override;
|
||||
virtual QColor getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const override;
|
||||
virtual PDFColor getDefaultColorOriginal() const override;
|
||||
virtual QColor getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const override;
|
||||
virtual size_t getColorComponentCount() const override;
|
||||
virtual QImage getImage(const PDFImageData& imageData,
|
||||
|
@ -735,7 +737,7 @@ public:
|
|||
|
||||
virtual ColorSpace getColorSpace() const override { return ColorSpace::Separation; }
|
||||
virtual bool equals(const PDFAbstractColorSpace* other) const override;
|
||||
virtual QColor getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const override;
|
||||
virtual PDFColor getDefaultColorOriginal() const override;
|
||||
virtual QColor getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const override;
|
||||
virtual size_t getColorComponentCount() const override;
|
||||
|
||||
|
@ -798,7 +800,7 @@ public:
|
|||
|
||||
virtual ColorSpace getColorSpace() const override { return ColorSpace::DeviceN; }
|
||||
virtual bool equals(const PDFAbstractColorSpace* other) const override;
|
||||
virtual QColor getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const override;
|
||||
virtual PDFColor getDefaultColorOriginal() const override;
|
||||
virtual QColor getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const override;
|
||||
virtual size_t getColorComponentCount() const override;
|
||||
|
||||
|
@ -854,6 +856,7 @@ public:
|
|||
virtual ColorSpace getColorSpace() const override { return ColorSpace::Pattern; }
|
||||
virtual bool equals(const PDFAbstractColorSpace* other) const override;
|
||||
virtual QColor getDefaultColor(const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter) const override;
|
||||
virtual PDFColor getDefaultColorOriginal() const override;
|
||||
virtual QColor getColor(const PDFColor& color, const PDFCMS* cms, RenderingIntent intent, PDFRenderErrorReporter* reporter, bool isRange01) const override;
|
||||
virtual size_t getColorComponentCount() const override;
|
||||
virtual const PDFPatternColorSpace* asPatternColorSpace() const override { return this; }
|
||||
|
|
|
@ -289,9 +289,9 @@ void PDFPageContentProcessor::initializeProcessor()
|
|||
}
|
||||
|
||||
m_graphicState.setStrokeColorSpace(m_deviceGrayColorSpace);
|
||||
m_graphicState.setStrokeColor(m_deviceGrayColorSpace->getDefaultColor(m_CMS, m_graphicState.getRenderingIntent(), this));
|
||||
m_graphicState.setStrokeColor(m_deviceGrayColorSpace->getDefaultColor(m_CMS, m_graphicState.getRenderingIntent(), this), m_deviceGrayColorSpace->getDefaultColorOriginal());
|
||||
m_graphicState.setFillColorSpace(m_deviceGrayColorSpace);
|
||||
m_graphicState.setFillColor(m_deviceGrayColorSpace->getDefaultColor(m_CMS, m_graphicState.getRenderingIntent(), this));
|
||||
m_graphicState.setFillColor(m_deviceGrayColorSpace->getDefaultColor(m_CMS, m_graphicState.getRenderingIntent(), this), m_deviceGrayColorSpace->getDefaultColorOriginal());
|
||||
m_graphicState.setStateFlags(PDFPageContentProcessorState::StateAll);
|
||||
updateGraphicState();
|
||||
}
|
||||
|
@ -996,8 +996,8 @@ void PDFPageContentProcessor::processTillingPatternPainting(const PDFTilingPatte
|
|||
m_graphicState.setFillColorSpace(uncoloredPatternColorSpace);
|
||||
|
||||
QColor color = uncoloredPatternColorSpace->getCheckedColor(uncoloredPatternColor, m_CMS, m_graphicState.getRenderingIntent(), this);
|
||||
m_graphicState.setStrokeColor(color);
|
||||
m_graphicState.setFillColor(color);
|
||||
m_graphicState.setStrokeColor(color, uncoloredPatternColor);
|
||||
m_graphicState.setFillColor(color, uncoloredPatternColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1006,8 +1006,8 @@ void PDFPageContentProcessor::processTillingPatternPainting(const PDFTilingPatte
|
|||
m_graphicState.setFillColorSpace(m_deviceGrayColorSpace);
|
||||
|
||||
QColor color = m_deviceGrayColorSpace->getDefaultColor(m_CMS, m_graphicState.getRenderingIntent(), this);
|
||||
m_graphicState.setStrokeColor(color);
|
||||
m_graphicState.setFillColor(color);
|
||||
m_graphicState.setStrokeColor(color, m_deviceGrayColorSpace->getDefaultColorOriginal());
|
||||
m_graphicState.setFillColor(color, m_deviceGrayColorSpace->getDefaultColorOriginal());
|
||||
}
|
||||
|
||||
updateGraphicState();
|
||||
|
@ -2305,7 +2305,7 @@ void PDFPageContentProcessor::operatorColorSetStrokingColorSpace(PDFPageContentP
|
|||
{
|
||||
// We must also set default color (it can depend on the color space)
|
||||
m_graphicState.setStrokeColorSpace(colorSpace);
|
||||
m_graphicState.setStrokeColor(colorSpace->getDefaultColor(m_CMS, m_graphicState.getRenderingIntent(), this));
|
||||
m_graphicState.setStrokeColor(colorSpace->getDefaultColor(m_CMS, m_graphicState.getRenderingIntent(), this), colorSpace->getDefaultColorOriginal());
|
||||
updateGraphicState();
|
||||
checkStrokingColor();
|
||||
}
|
||||
|
@ -2328,7 +2328,7 @@ void PDFPageContentProcessor::operatorColorSetFillingColorSpace(PDFOperandName n
|
|||
{
|
||||
// We must also set default color (it can depend on the color space)
|
||||
m_graphicState.setFillColorSpace(colorSpace);
|
||||
m_graphicState.setFillColor(colorSpace->getDefaultColor(m_CMS, m_graphicState.getRenderingIntent(), this));
|
||||
m_graphicState.setFillColor(colorSpace->getDefaultColor(m_CMS, m_graphicState.getRenderingIntent(), this), colorSpace->getDefaultColorOriginal());
|
||||
updateGraphicState();
|
||||
checkFillingColor();
|
||||
}
|
||||
|
@ -2357,7 +2357,7 @@ void PDFPageContentProcessor::operatorColorSetStrokingColor()
|
|||
{
|
||||
color.push_back(readOperand<PDFReal>(i));
|
||||
}
|
||||
m_graphicState.setStrokeColor(colorSpace->getColor(color, m_CMS, m_graphicState.getRenderingIntent(), this, true));
|
||||
m_graphicState.setStrokeColor(colorSpace->getColor(color, m_CMS, m_graphicState.getRenderingIntent(), this, true), color);
|
||||
updateGraphicState();
|
||||
checkStrokingColor();
|
||||
}
|
||||
|
@ -2435,7 +2435,7 @@ void PDFPageContentProcessor::operatorColorSetFillingColor()
|
|||
{
|
||||
color.push_back(readOperand<PDFReal>(i));
|
||||
}
|
||||
m_graphicState.setFillColor(colorSpace->getColor(color, m_CMS, m_graphicState.getRenderingIntent(), this, true));
|
||||
m_graphicState.setFillColor(colorSpace->getColor(color, m_CMS, m_graphicState.getRenderingIntent(), this, true), color);
|
||||
updateGraphicState();
|
||||
checkFillingColor();
|
||||
}
|
||||
|
@ -2503,7 +2503,7 @@ void PDFPageContentProcessor::operatorColorSetDeviceGrayStroking(PDFReal gray)
|
|||
}
|
||||
|
||||
m_graphicState.setStrokeColorSpace(m_deviceGrayColorSpace);
|
||||
m_graphicState.setStrokeColor(getColorFromColorSpace(m_graphicState.getStrokeColorSpace(), gray));
|
||||
m_graphicState.setStrokeColor(getColorFromColorSpace(m_graphicState.getStrokeColorSpace(), gray), PDFColor(PDFColorComponent(gray)));
|
||||
updateGraphicState();
|
||||
checkStrokingColor();
|
||||
}
|
||||
|
@ -2517,7 +2517,7 @@ void PDFPageContentProcessor::operatorColorSetDeviceGrayFilling(PDFReal gray)
|
|||
}
|
||||
|
||||
m_graphicState.setFillColorSpace(m_deviceGrayColorSpace);
|
||||
m_graphicState.setFillColor(getColorFromColorSpace(m_graphicState.getFillColorSpace(), gray));
|
||||
m_graphicState.setFillColor(getColorFromColorSpace(m_graphicState.getFillColorSpace(), gray), PDFColor(PDFColorComponent(gray)));
|
||||
updateGraphicState();
|
||||
checkFillingColor();
|
||||
}
|
||||
|
@ -2531,7 +2531,7 @@ void PDFPageContentProcessor::operatorColorSetDeviceRGBStroking(PDFReal r, PDFRe
|
|||
}
|
||||
|
||||
m_graphicState.setStrokeColorSpace(m_deviceRGBColorSpace);
|
||||
m_graphicState.setStrokeColor(getColorFromColorSpace(m_graphicState.getStrokeColorSpace(), r, g, b));
|
||||
m_graphicState.setStrokeColor(getColorFromColorSpace(m_graphicState.getStrokeColorSpace(), r, g, b), PDFColor(PDFColorComponent(r), PDFColorComponent(g), PDFColorComponent(b)));
|
||||
updateGraphicState();
|
||||
checkStrokingColor();
|
||||
}
|
||||
|
@ -2545,7 +2545,7 @@ void PDFPageContentProcessor::operatorColorSetDeviceRGBFilling(PDFReal r, PDFRea
|
|||
}
|
||||
|
||||
m_graphicState.setFillColorSpace(m_deviceRGBColorSpace);
|
||||
m_graphicState.setFillColor(getColorFromColorSpace(m_graphicState.getFillColorSpace(), r, g, b));
|
||||
m_graphicState.setFillColor(getColorFromColorSpace(m_graphicState.getFillColorSpace(), r, g, b), PDFColor(PDFColorComponent(r), PDFColorComponent(g), PDFColorComponent(b)));
|
||||
updateGraphicState();
|
||||
checkFillingColor();
|
||||
}
|
||||
|
@ -2559,7 +2559,7 @@ void PDFPageContentProcessor::operatorColorSetDeviceCMYKStroking(PDFReal c, PDFR
|
|||
}
|
||||
|
||||
m_graphicState.setStrokeColorSpace(m_deviceCMYKColorSpace);
|
||||
m_graphicState.setStrokeColor(getColorFromColorSpace(m_graphicState.getStrokeColorSpace(), c, m, y, k));
|
||||
m_graphicState.setStrokeColor(getColorFromColorSpace(m_graphicState.getStrokeColorSpace(), c, m, y, k), PDFColor(PDFColorComponent(c), PDFColorComponent(m), PDFColorComponent(y), PDFColorComponent(k)));
|
||||
updateGraphicState();
|
||||
checkStrokingColor();
|
||||
}
|
||||
|
@ -2573,7 +2573,7 @@ void PDFPageContentProcessor::operatorColorSetDeviceCMYKFilling(PDFReal c, PDFRe
|
|||
}
|
||||
|
||||
m_graphicState.setFillColorSpace(m_deviceCMYKColorSpace);
|
||||
m_graphicState.setFillColor(getColorFromColorSpace(m_graphicState.getFillColorSpace(), c, m, y, k));
|
||||
m_graphicState.setFillColor(getColorFromColorSpace(m_graphicState.getFillColorSpace(), c, m, y, k), PDFColor(PDFColorComponent(c), PDFColorComponent(m), PDFColorComponent(y), PDFColorComponent(k)));
|
||||
updateGraphicState();
|
||||
checkFillingColor();
|
||||
}
|
||||
|
@ -3324,7 +3324,9 @@ PDFPageContentProcessor::PDFPageContentProcessorState::PDFPageContentProcessorSt
|
|||
m_fillColorSpace(),
|
||||
m_strokeColorSpace(),
|
||||
m_fillColor(Qt::black),
|
||||
m_fillColorOriginal(),
|
||||
m_strokeColor(Qt::black),
|
||||
m_strokeColorOriginal(),
|
||||
m_lineWidth(1.0),
|
||||
m_lineCapStyle(Qt::FlatCap),
|
||||
m_lineJoinStyle(Qt::MiterJoin),
|
||||
|
@ -3353,6 +3355,9 @@ PDFPageContentProcessor::PDFPageContentProcessorState::PDFPageContentProcessorSt
|
|||
{
|
||||
m_fillColorSpace.reset(new PDFDeviceGrayColorSpace);
|
||||
m_strokeColorSpace = m_fillColorSpace;
|
||||
|
||||
m_fillColorOriginal = m_fillColorSpace->getDefaultColorOriginal();
|
||||
m_strokeColorOriginal = m_fillColorOriginal;
|
||||
}
|
||||
|
||||
PDFPageContentProcessor::PDFPageContentProcessorState::~PDFPageContentProcessorState()
|
||||
|
@ -3365,8 +3370,8 @@ PDFPageContentProcessor::PDFPageContentProcessorState& PDFPageContentProcessor::
|
|||
setCurrentTransformationMatrix(other.getCurrentTransformationMatrix());
|
||||
setStrokeColorSpace(other.m_strokeColorSpace);
|
||||
setFillColorSpace(other.m_fillColorSpace);
|
||||
setStrokeColor(other.getStrokeColor());
|
||||
setFillColor(other.getFillColor());
|
||||
setStrokeColor(other.getStrokeColor(), other.getStrokeColorOriginal());
|
||||
setFillColor(other.getFillColor(), other.getFillColorOriginal());
|
||||
setLineWidth(other.getLineWidth());
|
||||
setLineCapStyle(other.getLineCapStyle());
|
||||
setLineJoinStyle(other.getLineJoinStyle());
|
||||
|
@ -3430,20 +3435,22 @@ void PDFPageContentProcessor::PDFPageContentProcessorState::setFillColorSpace(co
|
|||
}
|
||||
}
|
||||
|
||||
void PDFPageContentProcessor::PDFPageContentProcessorState::setStrokeColor(const QColor& strokeColor)
|
||||
void PDFPageContentProcessor::PDFPageContentProcessorState::setStrokeColor(const QColor& strokeColor, const PDFColor& originalColor)
|
||||
{
|
||||
if (m_strokeColor != strokeColor)
|
||||
{
|
||||
m_strokeColor = strokeColor;
|
||||
m_strokeColorOriginal = originalColor;
|
||||
m_stateFlags |= StateStrokeColor;
|
||||
}
|
||||
}
|
||||
|
||||
void PDFPageContentProcessor::PDFPageContentProcessorState::setFillColor(const QColor& fillColor)
|
||||
void PDFPageContentProcessor::PDFPageContentProcessorState::setFillColor(const QColor& fillColor, const PDFColor& originalColor)
|
||||
{
|
||||
if (m_fillColor != fillColor)
|
||||
{
|
||||
m_fillColor = fillColor;
|
||||
m_fillColorOriginal = originalColor;
|
||||
m_stateFlags |= StateFillColor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -330,10 +330,12 @@ protected:
|
|||
void setFillColorSpace(const QSharedPointer<PDFAbstractColorSpace>& fillColorSpace);
|
||||
|
||||
const QColor& getStrokeColor() const { return m_strokeColor; }
|
||||
void setStrokeColor(const QColor& strokeColor);
|
||||
const PDFColor& getStrokeColorOriginal() const { return m_strokeColorOriginal; }
|
||||
void setStrokeColor(const QColor& strokeColor, const PDFColor& originalColor);
|
||||
|
||||
const QColor& getFillColor() const { return m_fillColor; }
|
||||
void setFillColor(const QColor& fillColor);
|
||||
const PDFColor& getFillColorOriginal() const { return m_fillColorOriginal; }
|
||||
void setFillColor(const QColor& fillColor, const PDFColor& originalColor);
|
||||
|
||||
PDFReal getLineWidth() const { return m_lineWidth; }
|
||||
void setLineWidth(PDFReal lineWidth);
|
||||
|
@ -448,7 +450,9 @@ protected:
|
|||
PDFColorSpacePointer m_strokeColorSpace;
|
||||
PDFColorSpacePointer m_fillColorSpace;
|
||||
QColor m_strokeColor;
|
||||
PDFColor m_strokeColorOriginal;
|
||||
QColor m_fillColor;
|
||||
PDFColor m_fillColorOriginal;
|
||||
PDFReal m_lineWidth;
|
||||
Qt::PenCapStyle m_lineCapStyle;
|
||||
Qt::PenJoinStyle m_lineJoinStyle;
|
||||
|
|
|
@ -514,12 +514,12 @@ void PDFFloatBitmapWithColorSpace::convertToColorSpace(const PDFCMS* cms,
|
|||
Q_ASSERT(sourceProcessColorBuffer.size() <= targetBuffer.size());
|
||||
|
||||
// Copy process colors
|
||||
auto targetIt = targetBuffer.begin();
|
||||
PDFColorComponent* targetIt = targetBuffer.begin();
|
||||
targetIt = std::copy(sourceProcessColorBuffer.cbegin(), sourceProcessColorBuffer.cend(), targetIt);
|
||||
|
||||
Q_ASSERT(std::distance(targetIt, targetBuffer.end()) == temporary.getPixelFormat().getSpotColorChannelCount() + temporary.getPixelFormat().getAuxiliaryChannelCount());
|
||||
|
||||
auto sourceIt = std::next(sourceSpotColorAndOpacityBuffer.cbegin(), temporary.getPixelFormat().getProcessColorChannelCount());
|
||||
const PDFColorComponent* sourceIt = std::next(sourceSpotColorAndOpacityBuffer.cbegin(), getPixelFormat().getProcessColorChannelCount());
|
||||
targetIt = std::copy(sourceIt, sourceSpotColorAndOpacityBuffer.cend(), targetIt);
|
||||
|
||||
Q_ASSERT(targetIt == targetBuffer.cend());
|
||||
|
@ -571,6 +571,8 @@ void PDFTransparencyRenderer::beginPaint(QSize pixelSize)
|
|||
Q_ASSERT(m_deviceColorSpace);
|
||||
Q_ASSERT(m_processColorSpace);
|
||||
|
||||
m_painterStateStack.push(PDFTransparencyPainterState());
|
||||
|
||||
PDFPixelFormat pixelFormat = PDFPixelFormat::createFormat(uint8_t(m_deviceColorSpace->getColorComponentCount()),
|
||||
uint8_t(m_inkMapper->getActiveSpotColorCount()),
|
||||
true, m_deviceColorSpace->getColorComponentCount() == 4);
|
||||
|
@ -606,6 +608,7 @@ const PDFFloatBitmap& PDFTransparencyRenderer::endPaint()
|
|||
Q_ASSERT(m_active);
|
||||
m_pageTransparencyGroupGuard.reset();
|
||||
m_active = false;
|
||||
m_painterStateStack.pop();
|
||||
|
||||
return *getImmediateBackdrop();
|
||||
}
|
||||
|
@ -616,18 +619,39 @@ void PDFTransparencyRenderer::performPathPainting(const QPainterPath& path, bool
|
|||
|
||||
void PDFTransparencyRenderer::performClipping(const QPainterPath& path, Qt::FillRule fillRule)
|
||||
{
|
||||
Q_UNUSED(fillRule);
|
||||
|
||||
PDFTransparencyPainterState* painterState = getPainterState();
|
||||
|
||||
if (!painterState->clipPath.isEmpty())
|
||||
{
|
||||
painterState->clipPath = painterState->clipPath.intersected(getCurrentWorldMatrix().map(path));
|
||||
}
|
||||
else
|
||||
{
|
||||
painterState->clipPath = getCurrentWorldMatrix().map(path);
|
||||
}
|
||||
}
|
||||
|
||||
void PDFTransparencyRenderer::performUpdateGraphicsState(const PDFPageContentProcessorState& state)
|
||||
{
|
||||
Q_UNUSED(state);
|
||||
}
|
||||
|
||||
void PDFTransparencyRenderer::performSaveGraphicState(ProcessOrder order)
|
||||
{
|
||||
if (order == ProcessOrder::AfterOperation)
|
||||
{
|
||||
m_painterStateStack.push(m_painterStateStack.top());
|
||||
}
|
||||
}
|
||||
|
||||
void PDFTransparencyRenderer::performRestoreGraphicState(ProcessOrder order)
|
||||
{
|
||||
if (order == ProcessOrder::BeforeOperation)
|
||||
{
|
||||
m_painterStateStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
void PDFTransparencyRenderer::performBeginTransparencyGroup(ProcessOrder order, const PDFTransparencyGroup& transparencyGroup)
|
||||
|
@ -715,6 +739,26 @@ void PDFTransparencyRenderer::performEndTransparencyGroup(ProcessOrder order, co
|
|||
}
|
||||
}
|
||||
|
||||
PDFReal PDFTransparencyRenderer::getShapeStroking() const
|
||||
{
|
||||
return getGraphicState()->getAlphaIsShape() ? getGraphicState()->getAlphaStroking() : 1.0;
|
||||
}
|
||||
|
||||
PDFReal PDFTransparencyRenderer::getOpacityStroking() const
|
||||
{
|
||||
return !getGraphicState()->getAlphaIsShape() ? getGraphicState()->getAlphaStroking() : 1.0;
|
||||
}
|
||||
|
||||
PDFReal PDFTransparencyRenderer::getShapeFilling() const
|
||||
{
|
||||
return getGraphicState()->getAlphaIsShape() ? getGraphicState()->getAlphaFilling() : 1.0;
|
||||
}
|
||||
|
||||
PDFReal PDFTransparencyRenderer::getOpacityFilling() const
|
||||
{
|
||||
return !getGraphicState()->getAlphaIsShape() ? getGraphicState()->getAlphaFilling() : 1.0;
|
||||
}
|
||||
|
||||
void PDFTransparencyRenderer::removeInitialBackdrop()
|
||||
{
|
||||
PDFFloatBitmapWithColorSpace* immediateBackdrop = getImmediateBackdrop();
|
||||
|
|
|
@ -326,6 +326,12 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
PDFReal getShapeStroking() const;
|
||||
PDFReal getOpacityStroking() const;
|
||||
PDFReal getShapeFilling() const;
|
||||
PDFReal getOpacityFilling() const;
|
||||
|
||||
|
||||
struct PDFTransparencyGroupPainterData
|
||||
{
|
||||
PDFTransparencyGroup group;
|
||||
|
@ -341,6 +347,11 @@ private:
|
|||
PDFColorSpacePointer blendColorSpace;
|
||||
};
|
||||
|
||||
struct PDFTransparencyPainterState
|
||||
{
|
||||
QPainterPath clipPath; ///< Clipping path in device state coordinates
|
||||
};
|
||||
|
||||
void removeInitialBackdrop();
|
||||
|
||||
PDFFloatBitmapWithColorSpace* getInitialBackdrop();
|
||||
|
@ -348,6 +359,8 @@ private:
|
|||
PDFFloatBitmapWithColorSpace* getBackdrop();
|
||||
const PDFColorSpacePointer& getBlendColorSpace() const;
|
||||
|
||||
PDFTransparencyPainterState* getPainterState() { return &m_painterStateStack.top(); }
|
||||
|
||||
bool isTransparencyGroupIsolated() const;
|
||||
bool isTransparencyGroupKnockout() const;
|
||||
|
||||
|
@ -355,6 +368,7 @@ private:
|
|||
PDFColorSpacePointer m_processColorSpace; ///< Process color space (color space, in which is page graphic's blended)
|
||||
std::unique_ptr<PDFTransparencyGroupGuard> m_pageTransparencyGroupGuard;
|
||||
std::vector<PDFTransparencyGroupPainterData> m_transparencyGroupDataStack;
|
||||
std::stack<PDFTransparencyPainterState> m_painterStateStack;
|
||||
const PDFInkMapper* m_inkMapper;
|
||||
bool m_active;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue