path: root/src/gui/painting/qpainter.cpp
diff options
authorAndre de la Rocha <>2018-09-07 19:16:23 +0200
committerAndre de la Rocha <>2018-10-25 22:03:23 +0000
commit9cd527bc1f384926985d63c741641316a66f17a4 (patch)
treebead94ef8e91053650bdb93e87940bd16b8a0022 /src/gui/painting/qpainter.cpp
parent5ea233ca6782eb27adf596515cb66ef3dadc1d5e (diff)
Add support for generating PDFs with losslessly encoded images
This patch adds the QPainter::LosslessImageRendering flag to QPainter::RenderHints and allows QPdfEngine to recognize it and encode images using a lossless data compression algorithm provided by zlib instead of using lossy JPEG compression, which can produce artifacts with some images. Task-number: QTBUG-54809 Change-Id: If9e2bc64da3bf3afcd5d6c74f0ee82336ef05a19 Reviewed-by: Lars Knoll <>
Diffstat (limited to 'src/gui/painting/qpainter.cpp')
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index b70b29e54e..df2f5e11d3 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -1437,6 +1437,13 @@ void QPainterPrivate::updateState(QPainterState *newState)
by slightly less than half a pixel. Also will treat default constructed pens
as cosmetic. Potentially useful when porting a Qt 4 application to Qt 5.
+ \value LosslessImageRendering Use a lossless image rendering, whenever possible.
+ Currently, this hint is only used when QPainter is employed to output a PDF
+ file through QPrinter or QPdfWriter, where drawImage()/drawPixmap() calls
+ will encode images using a lossless compression algorithm instead of lossy
+ JPEG compression.
+ This value was added in Qt 5.13.
\sa renderHints(), setRenderHint(), {QPainter#Rendering
Quality}{Rendering Quality}, {Concentric Circles Example}