Fixed bug in QPdfEngine::addImage causing mono images to be made 32 bit
authorMatthew Cattell <matthew.cattell@nokia.com>
Mon, 2 May 2011 09:26:05 +0000 (11:26 +0200)
committerOlivier Goffart <olivier.goffart@nokia.com>
Tue, 10 May 2011 10:54:53 +0000 (12:54 +0200)
Regression from 4.5 causing performance and size degradation.

Task-number: QTBUG-18997
Reviewed-by: Samuel
(cherry picked from commit 18122b473ecbd85ba953f70743b1756358bf7c0c)

src/gui/painting/qprintengine_pdf.cpp

index b7f5160..353869f 100644 (file)
@@ -534,7 +534,10 @@ 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() == 0) {
+    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 (format == QImage::Format_MonoLSB)
             image = image.convertToFormat(QImage::Format_Mono);
         format = QImage::Format_Mono;