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:
@ -20,6 +20,7 @@
|
||||
#include "pdfdocument.h"
|
||||
#include "pdfexception.h"
|
||||
#include "pdfutils.h"
|
||||
#include "pdfpattern.h"
|
||||
|
||||
namespace pdf
|
||||
{
|
||||
@ -238,6 +239,16 @@ QImage PDFAbstractColorSpace::getImage(const PDFImageData& imageData) const
|
||||
return QImage();
|
||||
}
|
||||
|
||||
QColor PDFAbstractColorSpace::getCheckedColor(const PDFColor& color) const
|
||||
{
|
||||
if (getColorComponentCount() != color.size())
|
||||
{
|
||||
throw PDFParserException(PDFTranslationContext::tr("Invalid number of color components. Expected number is %1, actual number is %2.").arg(getColorComponentCount(), color.size()));
|
||||
}
|
||||
|
||||
return getColor(color);
|
||||
}
|
||||
|
||||
PDFColorSpacePointer PDFAbstractColorSpace::createColorSpace(const PDFDictionary* colorSpaceDictionary,
|
||||
const PDFDocument* document,
|
||||
const PDFObject& colorSpace)
|
||||
@ -252,6 +263,18 @@ PDFColorSpacePointer PDFAbstractColorSpace::createDeviceColorSpaceByName(const P
|
||||
return createDeviceColorSpaceByNameImpl(colorSpaceDictionary, document, name, COLOR_SPACE_MAX_LEVEL_OF_RECURSION);
|
||||
}
|
||||
|
||||
PDFColor PDFAbstractColorSpace::convertToColor(const std::vector<PDFReal>& components)
|
||||
{
|
||||
PDFColor result;
|
||||
|
||||
for (PDFReal component : components)
|
||||
{
|
||||
result.push_back(component);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
PDFColorSpacePointer PDFAbstractColorSpace::createColorSpaceImpl(const PDFDictionary* colorSpaceDictionary,
|
||||
const PDFDocument* document,
|
||||
const PDFObject& colorSpace,
|
||||
@ -293,6 +316,12 @@ PDFColorSpacePointer PDFAbstractColorSpace::createColorSpaceImpl(const PDFDictio
|
||||
{
|
||||
stream = colorSpaceSettings.getStream();
|
||||
}
|
||||
|
||||
if (name == COLOR_SPACE_NAME_PATTERN)
|
||||
{
|
||||
PDFPatternPtr pattern = PDFPattern::createPattern(colorSpaceDictionary, document, array->getItem(1));
|
||||
return PDFColorSpacePointer(new PDFPatternColorSpace(qMove(pattern)));
|
||||
}
|
||||
}
|
||||
|
||||
if (dictionary)
|
||||
@ -915,4 +944,19 @@ const unsigned char* PDFImageData::getRow(unsigned int rowIndex) const
|
||||
return data + (rowIndex * m_stride);
|
||||
}
|
||||
|
||||
QColor PDFPatternColorSpace::getDefaultColor() const
|
||||
{
|
||||
throw PDFParserException(PDFTranslationContext::tr("Pattern doesn't have default color."));
|
||||
}
|
||||
|
||||
QColor PDFPatternColorSpace::getColor(const PDFColor& color) const
|
||||
{
|
||||
throw PDFParserException(PDFTranslationContext::tr("Pattern doesn't have defined uniform color."));
|
||||
}
|
||||
|
||||
size_t PDFPatternColorSpace::getColorComponentCount() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace pdf
|
||||
|
Reference in New Issue
Block a user