Update acc. to spec PDF 2.0, chapter 7, color space of JPX image, minor parser update

This commit is contained in:
Jakub Melka
2020-07-10 17:08:22 +02:00
parent 863ae5a873
commit 4647633956
3 changed files with 23 additions and 12 deletions

View File

@ -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.")));
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)