summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpdf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting/qpdf.cpp')
-rw-r--r--src/gui/painting/qpdf.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index 473231b142..2efaec41ef 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -2317,6 +2317,14 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
return patternObj;
}
+static inline bool is_monochrome(const QVector<QRgb> &colorTable)
+{
+ return colorTable.size() == 2
+ && colorTable.at(0) == QColor(Qt::black).rgba()
+ && colorTable.at(1) == QColor(Qt::white).rgba()
+ ;
+}
+
/*!
* Adds an image to the pdf and return the pdf-object id. Returns -1 if adding the image failed.
*/
@@ -2331,10 +2339,7 @@ int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, qint64 serial_n
QImage image = img;
QImage::Format format = image.format();
- if (image.depth() == 1 && *bitmap && img.colorTable().size() == 2
- && img.colorTable().at(0) == QColor(Qt::black).rgba()
- && img.colorTable().at(1) == QColor(Qt::white).rgba())
- {
+ if (image.depth() == 1 && *bitmap && is_monochrome(img.colorTable())) {
if (format == QImage::Format_MonoLSB)
image = image.convertToFormat(QImage::Format_Mono);
format = QImage::Format_Mono;