mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Issue #202: Certain raster content not rendered
This commit is contained in:
@ -322,11 +322,7 @@ QImage PDFAbstractColorSpace::getImage(const PDFImageData& imageData,
|
|||||||
const unsigned int imageHeight = imageData.getHeight();
|
const unsigned int imageHeight = imageData.getHeight();
|
||||||
|
|
||||||
QImage alphaMask = createAlphaMask(softMask);
|
QImage alphaMask = createAlphaMask(softMask);
|
||||||
if (alphaMask.size() != image.size())
|
QSize targetSize = getLargerSizeByArea(alphaMask.size(), image.size());
|
||||||
{
|
|
||||||
// Scale the alpha mask, if it is masked
|
|
||||||
alphaMask = alphaMask.scaled(image.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
QMutex exceptionMutex;
|
QMutex exceptionMutex;
|
||||||
std::optional<PDFException> exception;
|
std::optional<PDFException> exception;
|
||||||
@ -347,7 +343,6 @@ QImage PDFAbstractColorSpace::getImage(const PDFImageData& imageData,
|
|||||||
const double max = reader.max();
|
const double max = reader.max();
|
||||||
const double coefficient = 1.0 / max;
|
const double coefficient = 1.0 / max;
|
||||||
unsigned char* outputLine = image.scanLine(i);
|
unsigned char* outputLine = image.scanLine(i);
|
||||||
unsigned char* alphaLine = alphaMask.scanLine(i);
|
|
||||||
|
|
||||||
std::vector<float> inputColors(imageWidth * componentCount, 0.0f);
|
std::vector<float> inputColors(imageWidth * componentCount, 0.0f);
|
||||||
std::vector<unsigned char> outputColors(imageWidth * 3, 0);
|
std::vector<unsigned char> outputColors(imageWidth * 3, 0);
|
||||||
@ -379,7 +374,7 @@ QImage PDFAbstractColorSpace::getImage(const PDFImageData& imageData,
|
|||||||
*outputLine++ = *transformedLine++;
|
*outputLine++ = *transformedLine++;
|
||||||
*outputLine++ = *transformedLine++;
|
*outputLine++ = *transformedLine++;
|
||||||
*outputLine++ = *transformedLine++;
|
*outputLine++ = *transformedLine++;
|
||||||
*outputLine++ = *alphaLine++;
|
*outputLine++ = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const PDFException &lineException)
|
catch (const PDFException &lineException)
|
||||||
@ -400,6 +395,18 @@ QImage PDFAbstractColorSpace::getImage(const PDFImageData& imageData,
|
|||||||
throw *exception;
|
throw *exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (image.size() != targetSize)
|
||||||
|
{
|
||||||
|
image = image.scaled(targetSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alphaMask.size() != targetSize)
|
||||||
|
{
|
||||||
|
alphaMask = alphaMask.scaled(targetSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
image.setAlphaChannel(alphaMask);
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1032,6 +1039,21 @@ bool PDFAbstractColorSpace::transform(const PDFAbstractColorSpace* source,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSize PDFAbstractColorSpace::getLargerSizeByArea(QSize s1, QSize s2)
|
||||||
|
{
|
||||||
|
int area1 = s1.width() * s1.height();
|
||||||
|
int area2 = s2.width() * s2.height();
|
||||||
|
|
||||||
|
if (area1 > area2)
|
||||||
|
{
|
||||||
|
return s1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return s2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PDFColorSpacePointer PDFAbstractColorSpace::createColorSpaceImpl(const PDFDictionary* colorSpaceDictionary,
|
PDFColorSpacePointer PDFAbstractColorSpace::createColorSpaceImpl(const PDFDictionary* colorSpaceDictionary,
|
||||||
const PDFDocument* document,
|
const PDFDocument* document,
|
||||||
const PDFObject& colorSpace,
|
const PDFObject& colorSpace,
|
||||||
@ -1947,11 +1969,7 @@ QImage PDFIndexedColorSpace::getImage(const PDFImageData& imageData,
|
|||||||
color.resize(1);
|
color.resize(1);
|
||||||
|
|
||||||
QImage alphaMask = createAlphaMask(softMask);
|
QImage alphaMask = createAlphaMask(softMask);
|
||||||
if (alphaMask.size() != image.size())
|
QSize targetSize = getLargerSizeByArea(alphaMask.size(), image.size());
|
||||||
{
|
|
||||||
// Scale the alpha mask, if it is masked
|
|
||||||
alphaMask = alphaMask.scaled(image.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int i = 0, rowCount = imageData.getHeight(); i < rowCount; ++i)
|
for (unsigned int i = 0, rowCount = imageData.getHeight(); i < rowCount; ++i)
|
||||||
{
|
{
|
||||||
@ -1963,7 +1981,6 @@ QImage PDFIndexedColorSpace::getImage(const PDFImageData& imageData,
|
|||||||
|
|
||||||
reader.seek(i * imageData.getStride());
|
reader.seek(i * imageData.getStride());
|
||||||
unsigned char* outputLine = image.scanLine(i);
|
unsigned char* outputLine = image.scanLine(i);
|
||||||
unsigned char* alphaLine = alphaMask.scanLine(i);
|
|
||||||
|
|
||||||
for (unsigned int j = 0; j < imageData.getWidth(); ++j)
|
for (unsigned int j = 0; j < imageData.getWidth(); ++j)
|
||||||
{
|
{
|
||||||
@ -1976,10 +1993,22 @@ QImage PDFIndexedColorSpace::getImage(const PDFImageData& imageData,
|
|||||||
*outputLine++ = qRed(rgb);
|
*outputLine++ = qRed(rgb);
|
||||||
*outputLine++ = qGreen(rgb);
|
*outputLine++ = qGreen(rgb);
|
||||||
*outputLine++ = qBlue(rgb);
|
*outputLine++ = qBlue(rgb);
|
||||||
*outputLine++ = *alphaLine++;
|
*outputLine++ = 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (image.size() != targetSize)
|
||||||
|
{
|
||||||
|
image = image.scaled(targetSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alphaMask.size() != targetSize)
|
||||||
|
{
|
||||||
|
alphaMask = alphaMask.scaled(targetSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
image.setAlphaChannel(alphaMask);
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,6 +456,8 @@ public:
|
|||||||
PDFRenderErrorReporter* reporter);
|
PDFRenderErrorReporter* reporter);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
static QSize getLargerSizeByArea(QSize s1, QSize s2);
|
||||||
|
|
||||||
/// Clips the color component to range [0, 1]
|
/// Clips the color component to range [0, 1]
|
||||||
static constexpr PDFColorComponent clip01(PDFColorComponent component) { return qBound<PDFColorComponent>(PDFColorComponent(0.0), component, PDFColorComponent(1.0)); }
|
static constexpr PDFColorComponent clip01(PDFColorComponent component) { return qBound<PDFColorComponent>(PDFColorComponent(0.0), component, PDFColorComponent(1.0)); }
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ CURRENT:
|
|||||||
- Issue #207: Zoom to Cursor (Zoom Anchoring)
|
- Issue #207: Zoom to Cursor (Zoom Anchoring)
|
||||||
- Issue #206: Name of the executable / command
|
- Issue #206: Name of the executable / command
|
||||||
- Issue #205: Editor cannot create white, whitesmoke or transparent annotations
|
- Issue #205: Editor cannot create white, whitesmoke or transparent annotations
|
||||||
|
- Issue #202: Certain raster content not rendered
|
||||||
- Issue #185: Latest git fails to build in linux
|
- Issue #185: Latest git fails to build in linux
|
||||||
|
|
||||||
V: 1.4.0.0 4.7.2024
|
V: 1.4.0.0 4.7.2024
|
||||||
|
Reference in New Issue
Block a user