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>
This commit is contained in:
parent
6cfdfad7d4
commit
b38145a11d
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user