mirror of
				https://github.com/JakubMelka/PDF4QT.git
				synced 2025-06-05 21:59:17 +02:00 
			
		
		
		
	Fix of internal compiler failure (MSVC 2019)
This commit is contained in:
		| @@ -698,6 +698,13 @@ void PDFFloatBitmap::fillChannel(size_t channel, PDFColorComponent value) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | PDFFloatBitmap PDFFloatBitmap::createOpaqueSoftMask(size_t width, size_t height) | ||||||
|  | { | ||||||
|  |     PDFFloatBitmap result(width, height, PDFPixelFormat::createOpacityMask()); | ||||||
|  |     result.makeOpaque(); | ||||||
|  |     return result; | ||||||
|  | } | ||||||
|  |  | ||||||
| PDFFloatBitmapWithColorSpace::PDFFloatBitmapWithColorSpace() | PDFFloatBitmapWithColorSpace::PDFFloatBitmapWithColorSpace() | ||||||
| { | { | ||||||
|  |  | ||||||
| @@ -945,14 +952,14 @@ QImage PDFTransparencyRenderer::toImageImpl(const PDFFloatBitmapWithColorSpace& | |||||||
|     return image; |     return image; | ||||||
| } | } | ||||||
|  |  | ||||||
| QImage PDFTransparencyRenderer::toImage(bool use16Bit, bool usePaper, PDFRGB paperColor) const | QImage PDFTransparencyRenderer::toImage(bool use16Bit, bool usePaper, const PDFRGB& paperColor) const | ||||||
| { | { | ||||||
|     QImage image; |     QImage image; | ||||||
|  |  | ||||||
|     if (m_transparencyGroupDataStack.size() == 1 && // We have finished the painting |     if (m_transparencyGroupDataStack.size() == 1 && // We have finished the painting | ||||||
|         m_transparencyGroupDataStack.back().immediateBackdrop.getPixelFormat().getProcessColorChannelCount() == 3) // We have exactly three process colors (RGB) |         getImmediateBackdrop()->getPixelFormat().getProcessColorChannelCount() == 3) // We have exactly three process colors (RGB) | ||||||
|     { |     { | ||||||
|         const PDFFloatBitmapWithColorSpace& floatImage = m_transparencyGroupDataStack.back().immediateBackdrop; |         const PDFFloatBitmapWithColorSpace& floatImage = *getImmediateBackdrop(); | ||||||
|         Q_ASSERT(floatImage.getPixelFormat().hasOpacityChannel()); |         Q_ASSERT(floatImage.getPixelFormat().hasOpacityChannel()); | ||||||
|  |  | ||||||
|         if (!usePaper) |         if (!usePaper) | ||||||
| @@ -961,13 +968,10 @@ QImage PDFTransparencyRenderer::toImage(bool use16Bit, bool usePaper, PDFRGB pap | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         PDFFloatBitmapWithColorSpace paperImage(floatImage.getWidth(), floatImage.getHeight(), floatImage.getPixelFormat(), floatImage.getColorSpace()); |         PDFFloatBitmapWithColorSpace paperImage(floatImage.getWidth(), floatImage.getHeight(), floatImage.getPixelFormat(), floatImage.getColorSpace()); | ||||||
|         paperImage.makeOpaque(); |         createPaperBitmap(paperImage, paperColor); | ||||||
|         paperImage.fillChannel(0, paperColor[0]); |  | ||||||
|         paperImage.fillChannel(1, paperColor[1]); |  | ||||||
|         paperImage.fillChannel(2, paperColor[2]); |  | ||||||
|  |  | ||||||
|         PDFFloatBitmap softMask(paperImage.getWidth(), paperImage.getHeight(), PDFPixelFormat::createOpacityMask()); |         PDFFloatBitmap softMask; | ||||||
|         softMask.makeOpaque(); |         createOpaqueSoftMask(softMask, paperImage.getWidth(), paperImage.getHeight()); | ||||||
|  |  | ||||||
|         QRect blendRegion(0, 0, int(floatImage.getWidth()), int(floatImage.getHeight())); |         QRect blendRegion(0, 0, int(floatImage.getWidth()), int(floatImage.getHeight())); | ||||||
|         PDFFloatBitmapWithColorSpace::blend(floatImage, paperImage, paperImage, paperImage, softMask, false, 1.0f, BlendMode::Normal, false, PDFFloatBitmap::OverprintMode::NoOveprint, blendRegion); |         PDFFloatBitmapWithColorSpace::blend(floatImage, paperImage, paperImage, paperImage, softMask, false, 1.0f, BlendMode::Normal, false, PDFFloatBitmap::OverprintMode::NoOveprint, blendRegion); | ||||||
| @@ -1261,6 +1265,12 @@ PDFFloatBitmapWithColorSpace PDFTransparencyRenderer::getColoredImage(const PDFI | |||||||
|         throw PDFException(PDFTranslationContext::tr("Invalid image color space.")); |         throw PDFException(PDFTranslationContext::tr("Invalid image color space.")); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     auto setColorSpaceAndMakeOpaque = [&](auto imageColorSpace) | ||||||
|  |     { | ||||||
|  |         result.setColorSpace(imageColorSpace); | ||||||
|  |         result.makeOpaque(); | ||||||
|  |     }; | ||||||
|  |  | ||||||
|     Q_ASSERT(imageData.isValid()); |     Q_ASSERT(imageData.isValid()); | ||||||
|     if (imageColorSpace->getColorSpace() == PDFAbstractColorSpace::ColorSpace::Indexed) |     if (imageColorSpace->getColorSpace() == PDFAbstractColorSpace::ColorSpace::Indexed) | ||||||
|     { |     { | ||||||
| @@ -1309,8 +1319,7 @@ PDFFloatBitmapWithColorSpace PDFTransparencyRenderer::getColoredImage(const PDFI | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         result = PDFFloatBitmapWithColorSpace(imageWidth, imageHeight, PDFPixelFormat::createFormat(uint8_t(colorComponentCount), 0, true, isCMYK, false)); |         result = PDFFloatBitmapWithColorSpace(imageWidth, imageHeight, PDFPixelFormat::createFormat(uint8_t(colorComponentCount), 0, true, isCMYK, false)); | ||||||
|         result.setColorSpace(imageColorSpace); |         setColorSpaceAndMakeOpaque(imageColorSpace); | ||||||
|         result.makeOpaque(); |  | ||||||
|  |  | ||||||
|         for (unsigned int i = 0; i < imageHeight; ++i) |         for (unsigned int i = 0; i < imageHeight; ++i) | ||||||
|         { |         { | ||||||
| @@ -1378,8 +1387,7 @@ PDFFloatBitmapWithColorSpace PDFTransparencyRenderer::getColoredImage(const PDFI | |||||||
|             case PDFImageData::MaskingType::None: |             case PDFImageData::MaskingType::None: | ||||||
|             { |             { | ||||||
|                 result = PDFFloatBitmapWithColorSpace(imageData.getWidth(), imageData.getHeight(), PDFPixelFormat::createFormat(uint8_t(colorComponentCount), 0, true, isCMYK, false)); |                 result = PDFFloatBitmapWithColorSpace(imageData.getWidth(), imageData.getHeight(), PDFPixelFormat::createFormat(uint8_t(colorComponentCount), 0, true, isCMYK, false)); | ||||||
|                 result.setColorSpace(imageColorSpace); |                 setColorSpaceAndMakeOpaque(imageColorSpace); | ||||||
|                 result.makeOpaque(); |  | ||||||
|  |  | ||||||
|                 unsigned int componentCount = imageData.getComponents(); |                 unsigned int componentCount = imageData.getComponents(); | ||||||
|                 if (componentCount != colorComponentCount) |                 if (componentCount != colorComponentCount) | ||||||
| @@ -1534,8 +1542,7 @@ PDFFloatBitmapWithColorSpace PDFTransparencyRenderer::getColoredImage(const PDFI | |||||||
|             case PDFImageData::MaskingType::ColorKeyMasking: |             case PDFImageData::MaskingType::ColorKeyMasking: | ||||||
|             { |             { | ||||||
|                 result = PDFFloatBitmapWithColorSpace(imageData.getWidth(), imageData.getHeight(), PDFPixelFormat::createFormat(uint8_t(colorComponentCount), 0, true, isCMYK, false)); |                 result = PDFFloatBitmapWithColorSpace(imageData.getWidth(), imageData.getHeight(), PDFPixelFormat::createFormat(uint8_t(colorComponentCount), 0, true, isCMYK, false)); | ||||||
|                 result.setColorSpace(imageColorSpace); |                 setColorSpaceAndMakeOpaque(imageColorSpace); | ||||||
|                 result.makeOpaque(); |  | ||||||
|  |  | ||||||
|                 unsigned int componentCount = imageData.getComponents(); |                 unsigned int componentCount = imageData.getComponents(); | ||||||
|                 if (componentCount != colorComponentCount) |                 if (componentCount != colorComponentCount) | ||||||
| @@ -1691,6 +1698,19 @@ PDFFloatBitmap PDFTransparencyRenderer::getAlphaMaskFromSoftMask(const PDFImageD | |||||||
|     return result; |     return result; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void PDFTransparencyRenderer::createOpaqueBitmap(PDFFloatBitmap& bitmap) | ||||||
|  | { | ||||||
|  |     bitmap.makeOpaque(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void PDFTransparencyRenderer::createPaperBitmap(PDFFloatBitmap& bitmap, const PDFRGB& paperColor) | ||||||
|  | { | ||||||
|  |     bitmap.makeOpaque(); | ||||||
|  |     bitmap.fillChannel(0, paperColor[0]); | ||||||
|  |     bitmap.fillChannel(1, paperColor[1]); | ||||||
|  |     bitmap.fillChannel(2, paperColor[2]); | ||||||
|  | } | ||||||
|  |  | ||||||
| void PDFTransparencyRenderer::performPathPainting(const QPainterPath& path, bool stroke, bool fill, bool text, Qt::FillRule fillRule) | void PDFTransparencyRenderer::performPathPainting(const QPainterPath& path, bool stroke, bool fill, bool text, Qt::FillRule fillRule) | ||||||
| { | { | ||||||
|     Q_UNUSED(text); |     Q_UNUSED(text); | ||||||
|   | |||||||
| @@ -24,6 +24,8 @@ | |||||||
| #include "pdfconstants.h" | #include "pdfconstants.h" | ||||||
| #include "pdfutils.h" | #include "pdfutils.h" | ||||||
|  |  | ||||||
|  | #include <QImage> | ||||||
|  |  | ||||||
| namespace pdf | namespace pdf | ||||||
| { | { | ||||||
|  |  | ||||||
| @@ -140,6 +142,12 @@ public: | |||||||
|     explicit PDFFloatBitmap(); |     explicit PDFFloatBitmap(); | ||||||
|     explicit PDFFloatBitmap(size_t width, size_t height, PDFPixelFormat format); |     explicit PDFFloatBitmap(size_t width, size_t height, PDFPixelFormat format); | ||||||
|  |  | ||||||
|  |     PDFFloatBitmap(const PDFFloatBitmap&) = default; | ||||||
|  |     PDFFloatBitmap(PDFFloatBitmap&&) = default; | ||||||
|  |  | ||||||
|  |     PDFFloatBitmap& operator=(const PDFFloatBitmap&) = default; | ||||||
|  |     PDFFloatBitmap& operator=(PDFFloatBitmap&&) = default; | ||||||
|  |  | ||||||
|     /// Returns buffer with pixel channels |     /// Returns buffer with pixel channels | ||||||
|     PDFColorBuffer getPixel(size_t x, size_t y); |     PDFColorBuffer getPixel(size_t x, size_t y); | ||||||
|  |  | ||||||
| @@ -268,6 +276,11 @@ public: | |||||||
|     void fillProcessColorChannels(PDFColorComponent value); |     void fillProcessColorChannels(PDFColorComponent value); | ||||||
|     void fillChannel(size_t channel, PDFColorComponent value); |     void fillChannel(size_t channel, PDFColorComponent value); | ||||||
|  |  | ||||||
|  |     /// Creates opaque soft mask of given size | ||||||
|  |     /// \param width Width | ||||||
|  |     /// \param height Height | ||||||
|  |     static PDFFloatBitmap createOpaqueSoftMask(size_t width, size_t height); | ||||||
|  |  | ||||||
| private: | private: | ||||||
|     PDFPixelFormat m_format; |     PDFPixelFormat m_format; | ||||||
|     std::size_t m_width; |     std::size_t m_width; | ||||||
| @@ -613,7 +626,8 @@ public: | |||||||
|     /// with paper color \p paperColor. |     /// with paper color \p paperColor. | ||||||
|     /// \param use16bit Produce 16-bit image instead of standard 8-bit |     /// \param use16bit Produce 16-bit image instead of standard 8-bit | ||||||
|     /// \param usePaper Blend image with opaque paper, with color \p paperColor |     /// \param usePaper Blend image with opaque paper, with color \p paperColor | ||||||
|     QImage toImage(bool use16Bit, bool usePaper = false, PDFRGB paperColor = PDFRGB()) const; |     /// \param paperColor Paper color | ||||||
|  |     QImage toImage(bool use16Bit, bool usePaper, const PDFRGB& paperColor) const; | ||||||
|  |  | ||||||
|     virtual void performPathPainting(const QPainterPath& path, bool stroke, bool fill, bool text, Qt::FillRule fillRule) override; |     virtual void performPathPainting(const QPainterPath& path, bool stroke, bool fill, bool text, Qt::FillRule fillRule) override; | ||||||
|     virtual bool performPathPaintingUsingShading(const QPainterPath& path, bool stroke, bool fill, const PDFShadingPattern* shadingPattern) override; |     virtual bool performPathPaintingUsingShading(const QPainterPath& path, bool stroke, bool fill, const PDFShadingPattern* shadingPattern) override; | ||||||
| @@ -796,6 +810,10 @@ private: | |||||||
|     /// \param imageData Soft mask data |     /// \param imageData Soft mask data | ||||||
|     PDFFloatBitmap getAlphaMaskFromSoftMask(const PDFImageData& softMask); |     PDFFloatBitmap getAlphaMaskFromSoftMask(const PDFImageData& softMask); | ||||||
|  |  | ||||||
|  |     static void createOpaqueBitmap(PDFFloatBitmap& bitmap); | ||||||
|  |     static void createPaperBitmap(PDFFloatBitmap& bitmap, const PDFRGB& paperColor); | ||||||
|  |     static void createOpaqueSoftMask(PDFFloatBitmap& softMask, size_t width, size_t height) { softMask = PDFFloatBitmap::createOpaqueSoftMask(width, height); } | ||||||
|  |  | ||||||
|     PDFColorSpacePointer m_deviceColorSpace;    ///< Device color space (color space for final result) |     PDFColorSpacePointer m_deviceColorSpace;    ///< Device color space (color space for final result) | ||||||
|     PDFColorSpacePointer m_processColorSpace;   ///< Process color space (color space, in which is page graphic's blended) |     PDFColorSpacePointer m_processColorSpace;   ///< Process color space (color space, in which is page graphic's blended) | ||||||
|     std::unique_ptr<PDFTransparencyGroupGuard> m_pageTransparencyGroupGuard; |     std::unique_ptr<PDFTransparencyGroupGuard> m_pageTransparencyGroupGuard; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user