mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Output preview widget (first part)
This commit is contained in:
@@ -989,12 +989,13 @@ void PDFTransparencyRenderer::beginPaint(QSize pixelSize)
|
||||
Q_ASSERT(m_deviceColorSpace);
|
||||
Q_ASSERT(m_processColorSpace);
|
||||
|
||||
m_originalProcessBitmap = PDFFloatBitmapWithColorSpace();
|
||||
m_transparencyGroupDataStack.clear();
|
||||
m_painterStateStack.push(PDFTransparencyPainterState());
|
||||
|
||||
// Initialize initial opaque soft mask
|
||||
PDFFloatBitmap initialSoftMaskBitmap(pixelSize.width(), pixelSize.height(), PDFPixelFormat::createOpacityMask());
|
||||
initialSoftMaskBitmap.makeOpaque();
|
||||
PDFFloatBitmap initialSoftMaskBitmap;
|
||||
createOpaqueSoftMask(initialSoftMaskBitmap, pixelSize.width(), pixelSize.height());
|
||||
m_painterStateStack.top().softMask = PDFTransparencySoftMask(true, qMove(initialSoftMaskBitmap));
|
||||
|
||||
PDFPixelFormat pixelFormat = PDFPixelFormat::createFormat(uint8_t(m_deviceColorSpace->getColorComponentCount()),
|
||||
@@ -1033,6 +1034,7 @@ void PDFTransparencyRenderer::beginPaint(QSize pixelSize)
|
||||
m_settings.activeColorMask != PDFPixelFormat::getAllColorsMask());
|
||||
m_transparencyGroupDataStack.back().activeColorMask = m_settings.activeColorMask;
|
||||
m_transparencyGroupDataStack.back().transformSpotsToDevice = m_settings.flags.testFlag(PDFTransparencyRendererSettings::SeparationSimulation);
|
||||
m_transparencyGroupDataStack.back().saveOriginalImage = m_settings.flags.testFlag(PDFTransparencyRendererSettings::SaveOriginalProcessImage);
|
||||
}
|
||||
|
||||
const PDFFloatBitmap& PDFTransparencyRenderer::endPaint()
|
||||
@@ -2524,6 +2526,11 @@ void PDFTransparencyRenderer::performEndTransparencyGroup(ProcessOrder order, co
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceData.saveOriginalImage)
|
||||
{
|
||||
m_originalProcessBitmap = sourceData.immediateBackdrop;
|
||||
}
|
||||
|
||||
// Collapse spot colors
|
||||
if (sourceData.transformSpotsToDevice)
|
||||
{
|
||||
|
@@ -136,7 +136,7 @@ private:
|
||||
|
||||
/// Represents float bitmap with arbitrary color channel count. Bitmap can also
|
||||
/// have auxiliary channels, such as shape and opacity channels.
|
||||
class PDFFloatBitmap
|
||||
class Pdf4QtLIBSHARED_EXPORT PDFFloatBitmap
|
||||
{
|
||||
public:
|
||||
explicit PDFFloatBitmap();
|
||||
@@ -311,7 +311,7 @@ private:
|
||||
};
|
||||
|
||||
/// Float bitmap with color space
|
||||
class PDFFloatBitmapWithColorSpace : public PDFFloatBitmap
|
||||
class Pdf4QtLIBSHARED_EXPORT PDFFloatBitmapWithColorSpace : public PDFFloatBitmap
|
||||
{
|
||||
public:
|
||||
explicit PDFFloatBitmapWithColorSpace();
|
||||
@@ -602,6 +602,11 @@ struct PDFTransparencyRendererSettings
|
||||
|
||||
/// Display tiling patterns (if this flag is false, tiling patterns aren't processed)
|
||||
DisplayTilingPatterns = 0x0200,
|
||||
|
||||
/// Saves process image before it is transformed into device space
|
||||
/// and before separation simulation is applied. Active color mask
|
||||
/// is still applied to this image.
|
||||
SaveOriginalProcessImage = 0x0400,
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(Flags, Flag)
|
||||
@@ -671,6 +676,11 @@ public:
|
||||
/// \param color Color
|
||||
void clearColor(const PDFColor& color);
|
||||
|
||||
/// Returns original process bitmap, before it is transformed into device space,
|
||||
/// and before separation simulation is being processed. Active color mask is still
|
||||
/// applied to this image.
|
||||
PDFFloatBitmapWithColorSpace getOriginalProcessBitmap() const { return m_originalProcessBitmap; }
|
||||
|
||||
virtual bool isContentKindSuppressed(ContentKind kind) const 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;
|
||||
@@ -742,6 +752,7 @@ private:
|
||||
bool filterColorsUsingMask = false;
|
||||
uint32_t activeColorMask = PDFPixelFormat::getAllColorsMask();
|
||||
bool transformSpotsToDevice = false;
|
||||
bool saveOriginalImage = false;
|
||||
};
|
||||
|
||||
struct PDFTransparencyPainterState
|
||||
@@ -901,6 +912,7 @@ private:
|
||||
PDFCachedItem<PDFMappedColor> m_mappedFillColor;
|
||||
PDFTransparencyRendererSettings m_settings;
|
||||
PDFDrawBuffer m_drawBuffer;
|
||||
PDFFloatBitmapWithColorSpace m_originalProcessBitmap;
|
||||
};
|
||||
|
||||
} // namespace pdf
|
||||
|
@@ -28,7 +28,7 @@ int qt_default_dpi_y() { return 96; }
|
||||
namespace pdf
|
||||
{
|
||||
|
||||
int PDFWidgetUtils::getPixelSize(QPaintDevice* device, pdf::PDFReal sizeMM)
|
||||
int PDFWidgetUtils::getPixelSize(const QPaintDevice* device, pdf::PDFReal sizeMM)
|
||||
{
|
||||
const int width = device->width();
|
||||
const int height = device->height();
|
||||
@@ -43,21 +43,21 @@ int PDFWidgetUtils::getPixelSize(QPaintDevice* device, pdf::PDFReal sizeMM)
|
||||
}
|
||||
}
|
||||
|
||||
int PDFWidgetUtils::scaleDPI_x(QPaintDevice* device, int unscaledSize)
|
||||
int PDFWidgetUtils::scaleDPI_x(const QPaintDevice* device, int unscaledSize)
|
||||
{
|
||||
const double logicalDPI_x = device->logicalDpiX();
|
||||
const double defaultDPI_x = qt_default_dpi_x();
|
||||
return (logicalDPI_x / defaultDPI_x) * unscaledSize;
|
||||
}
|
||||
|
||||
int PDFWidgetUtils::scaleDPI_y(QPaintDevice* device, int unscaledSize)
|
||||
int PDFWidgetUtils::scaleDPI_y(const QPaintDevice* device, int unscaledSize)
|
||||
{
|
||||
const double logicalDPI_y = device->logicalDpiY();
|
||||
const double defaultDPI_y = qt_default_dpi_y();
|
||||
return (logicalDPI_y / defaultDPI_y) * unscaledSize;
|
||||
}
|
||||
|
||||
PDFReal PDFWidgetUtils::scaleDPI_x(QPaintDevice* device, PDFReal unscaledSize)
|
||||
PDFReal PDFWidgetUtils::scaleDPI_x(const QPaintDevice* device, PDFReal unscaledSize)
|
||||
{
|
||||
const double logicalDPI_x = device->logicalDpiX();
|
||||
const double defaultDPI_x = qt_default_dpi_x();
|
||||
@@ -77,7 +77,7 @@ void PDFWidgetUtils::scaleWidget(QWidget* widget, QSize unscaledSize)
|
||||
widget->resize(width, height);
|
||||
}
|
||||
|
||||
QSize PDFWidgetUtils::scaleDPI(QPaintDevice* widget, QSize unscaledSize)
|
||||
QSize PDFWidgetUtils::scaleDPI(const QPaintDevice* widget, QSize unscaledSize)
|
||||
{
|
||||
const double logicalDPI_x = widget->logicalDpiX();
|
||||
const double logicalDPI_y = widget->logicalDpiY();
|
||||
|
@@ -31,19 +31,19 @@ public:
|
||||
PDFWidgetUtils() = delete;
|
||||
|
||||
/// Converts size in MM to pixel size
|
||||
static int getPixelSize(QPaintDevice* device, pdf::PDFReal sizeMM);
|
||||
static int getPixelSize(const QPaintDevice* device, pdf::PDFReal sizeMM);
|
||||
|
||||
/// Scale horizontal DPI value
|
||||
/// \param device Paint device to obtain logical DPI for scaling
|
||||
static int scaleDPI_x(QPaintDevice* device, int unscaledSize);
|
||||
static int scaleDPI_x(const QPaintDevice* device, int unscaledSize);
|
||||
|
||||
/// Scale vertical DPI value
|
||||
/// \param device Paint device to obtain logical DPI for scaling
|
||||
static int scaleDPI_y(QPaintDevice* device, int unscaledSize);
|
||||
static int scaleDPI_y(const QPaintDevice* device, int unscaledSize);
|
||||
|
||||
/// Scale horizontal DPI value
|
||||
/// \param device Paint device to obtain logical DPI for scaling
|
||||
static PDFReal scaleDPI_x(QPaintDevice* device, PDFReal unscaledSize);
|
||||
static PDFReal scaleDPI_x(const QPaintDevice* device, PDFReal unscaledSize);
|
||||
|
||||
/// Scales widget based on DPI
|
||||
/// \param widget Widget to be scaled
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
/// Scales size based on DPI
|
||||
/// \param device Paint device to obtain logical DPI for scaling
|
||||
/// \param unscaledSize Unscaled size
|
||||
static QSize scaleDPI(QPaintDevice* widget, QSize unscaledSize);
|
||||
static QSize scaleDPI(const QPaintDevice* widget, QSize unscaledSize);
|
||||
};
|
||||
|
||||
} // namespace pdf
|
||||
|
Reference in New Issue
Block a user