mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-03-15 10:50:18 +01:00
Update acc. to spec PDF 2.0, chapter 7, color space of JPX image, minor parser update
This commit is contained in:
parent
863ae5a873
commit
4647633956
@ -531,11 +531,10 @@ private:
|
|||||||
|
|
||||||
class PDFICCBasedColorSpace : public PDFAbstractColorSpace
|
class PDFICCBasedColorSpace : public PDFAbstractColorSpace
|
||||||
{
|
{
|
||||||
private:
|
public:
|
||||||
static constexpr const size_t MAX_COLOR_COMPONENTS = 4;
|
static constexpr const size_t MAX_COLOR_COMPONENTS = 4;
|
||||||
using Ranges = std::array<PDFColorComponent, MAX_COLOR_COMPONENTS * 2>;
|
using Ranges = std::array<PDFColorComponent, MAX_COLOR_COMPONENTS * 2>;
|
||||||
|
|
||||||
public:
|
|
||||||
explicit PDFICCBasedColorSpace(PDFColorSpacePointer alternateColorSpace, Ranges range, QByteArray iccProfileData);
|
explicit PDFICCBasedColorSpace(PDFColorSpacePointer alternateColorSpace, Ranges range, QByteArray iccProfileData);
|
||||||
virtual ~PDFICCBasedColorSpace() = default;
|
virtual ~PDFICCBasedColorSpace() = default;
|
||||||
|
|
||||||
|
@ -461,6 +461,14 @@ PDFImage PDFImage::createImage(const PDFDocument* document,
|
|||||||
imageData.errors.push_back(PDFRenderError(RenderErrorType::Error, PDFTranslationContext::tr("Unknown color space for JPEG 2000 image.")));
|
imageData.errors.push_back(PDFRenderError(RenderErrorType::Error, PDFTranslationContext::tr("Unknown color space for JPEG 2000 image.")));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Jakub Melka: Try to use ICC profile, if image has it
|
||||||
|
if (jpegImage->icc_profile_buf && jpegImage->icc_profile_len > 0 && image.m_colorSpace)
|
||||||
|
{
|
||||||
|
QByteArray iccProfileData(reinterpret_cast<const char*>(jpegImage->icc_profile_buf), jpegImage->icc_profile_len);
|
||||||
|
PDFICCBasedColorSpace::Ranges ranges = { 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 };
|
||||||
|
image.m_colorSpace.reset(new PDFICCBasedColorSpace(image.m_colorSpace, ranges, qMove(iccProfileData)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// First we must check, if all components are valid (i.e has same width/height/precision)
|
// First we must check, if all components are valid (i.e has same width/height/precision)
|
||||||
|
@ -48,16 +48,18 @@ constexpr const char CHAR_SPACE = 0x20;
|
|||||||
|
|
||||||
// Group of delimiter characters
|
// Group of delimiter characters
|
||||||
|
|
||||||
constexpr const char CHAR_LEFT_BRACKET = '(';
|
constexpr const char CHAR_LEFT_BRACKET = '(';
|
||||||
constexpr const char CHAR_RIGHT_BRACKET = ')';
|
constexpr const char CHAR_RIGHT_BRACKET = ')';
|
||||||
constexpr const char CHAR_LEFT_ANGLE = '<';
|
constexpr const char CHAR_LEFT_ANGLE = '<';
|
||||||
constexpr const char CHAR_RIGHT_ANGLE = '>';
|
constexpr const char CHAR_RIGHT_ANGLE = '>';
|
||||||
constexpr const char CHAR_ARRAY_START = '[';
|
constexpr const char CHAR_ARRAY_START = '[';
|
||||||
constexpr const char CHAR_ARRAY_END = ']';
|
constexpr const char CHAR_ARRAY_END = ']';
|
||||||
constexpr const char CHAR_SLASH = '/';
|
constexpr const char CHAR_LEFT_CURLY_BRACKET = '{';
|
||||||
constexpr const char CHAR_PERCENT = '%';
|
constexpr const char CHAR_RIGHT_CURLY_BRACKET = '}';
|
||||||
constexpr const char CHAR_BACKSLASH = '\\';
|
constexpr const char CHAR_SLASH = '/';
|
||||||
constexpr const char CHAR_MARK = '#';
|
constexpr const char CHAR_PERCENT = '%';
|
||||||
|
constexpr const char CHAR_BACKSLASH = '\\';
|
||||||
|
constexpr const char CHAR_MARK = '#';
|
||||||
|
|
||||||
// These constants reserves memory while reading string or name
|
// These constants reserves memory while reading string or name
|
||||||
|
|
||||||
@ -371,6 +373,8 @@ constexpr bool PDFLexicalAnalyzer::isDelimiter(char character)
|
|||||||
case CHAR_RIGHT_ANGLE:
|
case CHAR_RIGHT_ANGLE:
|
||||||
case CHAR_ARRAY_START:
|
case CHAR_ARRAY_START:
|
||||||
case CHAR_ARRAY_END:
|
case CHAR_ARRAY_END:
|
||||||
|
case CHAR_LEFT_CURLY_BRACKET:
|
||||||
|
case CHAR_RIGHT_CURLY_BRACKET:
|
||||||
case CHAR_SLASH:
|
case CHAR_SLASH:
|
||||||
case CHAR_PERCENT:
|
case CHAR_PERCENT:
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user