diff options
author | Andy Shaw <andy.shaw@qt.io> | 2016-10-12 09:03:39 +0200 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2016-10-19 15:48:31 +0000 |
commit | b38145a11d03c3e3fe8baf37800a017359283861 (patch) | |
tree | 7d1d39bba7e92d5780e0d6d76045d3ae3d86527c /src | |
parent | 6cfdfad7d41a7e452fa53495d9843c5d67e74946 (diff) |
PDF: Handle monochrome images correctly
When an image is considered to be monochrome then it should not be
making the white part of the image transparent, the colors should be
kept as is.
Task-number: QTBUG-56489
Change-Id: I3621ca7be2a0ebe6852363f860c0b3de28d28a31
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/painting/qpdf.cpp | 13 | ||||
-rw-r--r-- | src/gui/painting/qpdf_p.h | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 0df5fd8b8a..77304fb87b 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1919,7 +1919,7 @@ int QPdfEnginePrivate::writeCompressed(const char *src, int len) } int QPdfEnginePrivate::writeImage(const QByteArray &data, int width, int height, int depth, - int maskObject, int softMaskObject, bool dct) + int maskObject, int softMaskObject, bool dct, bool isMono) { int image = addXrefEntry(-1); xprintf("<<\n" @@ -1929,8 +1929,13 @@ int QPdfEnginePrivate::writeImage(const QByteArray &data, int width, int height, "/Height %d\n", width, height); if (depth == 1) { - xprintf("/ImageMask true\n" - "/Decode [1 0]\n"); + if (!isMono) { + xprintf("/ImageMask true\n" + "/Decode [1 0]\n"); + } else { + xprintf("/BitsPerComponent 1\n" + "/ColorSpace /DeviceGray\n"); + } } else { xprintf("/BitsPerComponent 8\n" "/ColorSpace %s\n", (depth == 32) ? "/DeviceRGB" : "/DeviceGray"); @@ -2445,7 +2450,7 @@ int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, qint64 serial_n memcpy(rawdata, image.constScanLine(y), bytesPerLine); rawdata += bytesPerLine; } - object = writeImage(data, w, h, d, 0, 0); + object = writeImage(data, w, h, d, 0, 0, false, is_monochrome(img.colorTable())); } else { QByteArray softMaskData; bool dct = false; diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h index de30744ca2..ab7a218d89 100644 --- a/src/gui/painting/qpdf_p.h +++ b/src/gui/painting/qpdf_p.h @@ -289,7 +289,7 @@ private: int streampos; int writeImage(const QByteArray &data, int width, int height, int depth, - int maskObject, int softMaskObject, bool dct = false); + int maskObject, int softMaskObject, bool dct = false, bool isMono = false); void writePage(); int addXrefEntry(int object, bool printostr = true); |