View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0011059 | Scribus | Import / Export | public | 2012-09-01 18:44 | 2016-03-30 21:27 |
Reporter | JussiP | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | new | Resolution | open | ||
Platform | any | OS | any | OS Version | any |
Product Version | 1.5.0svn | ||||
Summary | 0011059: [PATCH] Fix overprinting for 1-bit images | ||||
Description | If you select "overprint" in image options, Scribus produces PDF commands that looks roughly like this: set graphics state to overprint draw image restore graphics state However the PDF spec says that overprinting does not work for images. It only works for draw operations using the current color. (PDF 1.3 spec, page 197) I examined the PDF output of some other programs and apparently the correct way to do this is to use the ImageMask entry in the image dictionary (PDF 1.3 spec, page 257). To get high quality 1 bit graphics with overprint, you have to do the following two changes: 1) remove "ColorSpace" and "Mask" (should not exist) and insert "ImageMask true" in the image's dictionary. 2) before issuing the "/imagename Do" command, set drawing color to black (c=m=y=0, K=1), all graphics state commands can remain as is. The UI should also be changed so it shows the overprinted images correctly. Visually this is identical to drawing the image in "multiply" blend mode. | ||||
Tags | comics, overprint, patch | ||||
Patch | Yes | ||||
child of | 0013013 | new | Metabug: Comics |
|
0001-Overprint-1-bit-images-using-ImageMasks.patch (1,964 bytes)
From 12cfc158942ea17e31850f74c4e0ee1ea3b01905 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen <jpakkane@gmail.com> Date: Mon, 17 Sep 2012 20:24:20 +0300 Subject: [PATCH 1/1] Overprint 1-bit images using ImageMasks. --- Scribus/scribus/pdflib_core.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Scribus/scribus/pdflib_core.cpp b/Scribus/scribus/pdflib_core.cpp index ce4a448..ee4a982 100644 --- a/Scribus/scribus/pdflib_core.cpp +++ b/Scribus/scribus/pdflib_core.cpp @@ -9855,10 +9855,18 @@ bool PDFLibCore::PDF_Image(PageItem* c, const QString& fn, double sx, double sy, int bytesWritten = 0; // Fixme: outType variable should be set directly in the if/else maze above. ColorSpaceEnum outType; + // Overprint does not work for images in general, but it does work + // for 1 bit images if they are drawn as image masks. + // PDF 1.3 spec, pages 197 and 257 + bool overprint1bitImage = false; if (img.imgInfo.colorspace == ColorSpaceMonochrome && c->effectsInUse.count() == 0) outType = ColorSpaceMonochrome; else outType = getOutputType(exportToGrayscale, exportToCMYK); + if(outType == ColorSpaceMonochrome + && img.imgInfo.colorspace == ColorSpaceMonochrome && + c->overprint()) + overprint1bitImage = true; if ((outType != ColorSpaceMonochrome) && (doc.HasCMS) && (Options.UseProfiles2)) { PutDoc("/ColorSpace "+ICCProfiles[profInUse].ICCArray+"\n"); @@ -9874,6 +9882,11 @@ bool PDFLibCore::PDF_Image(PageItem* c, const QString& fn, double sx, double sy, switch (outType) { case ColorSpaceMonochrome : + if (overprint1bitImage) + PutDoc("/ImageMask true\n"); + else + PutDoc("/ColorSpace /DeviceGray\n"); + break; case ColorSpaceGray : PutDoc("/ColorSpace /DeviceGray\n"); break; case ColorSpaceCMYK : PutDoc("/ColorSpace /DeviceCMYK\n"); break; default : PutDoc("/ColorSpace /DeviceRGB\n"); break; -- 1.7.10.4 |
|
Attached is a patch to make overprint export work. It assumes that the drawing color has been set to full black, which seems to be the case in my quick tests. I tried to make the UI draw the image correctly but could not make heads or tails of the code. |
|
I did some test with your patch. Apparently the drawing color is not always black, for example if a color background has been set in the image frame. In this case, the image simply disappears as it is drawn the same color as the background. I noticed another issue too : when a same image is put overprinted in one frame and knocked out in another frame, both image appears as overprinted after being exported. |
|
Now that I think about it, the described behavior is what we want. It allows the user to draw 1-bit overprint images in any color (even a custom spot color). The only fix needed would be not to fill the image frame when it contains a monochrome overprint image. I'll look into the other issue, hopefully soon. |
|
0001-Export-properly-formatted-overprint-images.patch (4,189 bytes)
From a1768f652ac7b694cc9faa58b6c352e20fcc0f28 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen <jpakkane@gmail.com> Date: Sun, 30 Sep 2012 17:04:58 +0300 Subject: [PATCH] Export properly formatted overprint images. --- Scribus/scribus/pdflib_core.cpp | 48 +++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/Scribus/scribus/pdflib_core.cpp b/Scribus/scribus/pdflib_core.cpp index ce4a448..74f419f 100644 --- a/Scribus/scribus/pdflib_core.cpp +++ b/Scribus/scribus/pdflib_core.cpp @@ -9347,6 +9347,17 @@ bool PDFLibCore::PDF_Image(PageItem* c, const QString& fn, double sx, double sy, double ax, ay, a2, a1; int origWidth = 1; int origHeight = 1; + QString cacheID; + + /* + * Overprinted images need different entries in their + * dictionaries. Deal with the case where an image is + * used both as overprint and as a regular image. + */ + if(c->overprint()) + cacheID = fn + "OVERPRINT"; + else + cacheID = fn; ShIm ImInfo; ImInfo.ResNum = 0; ImInfo.sxa = 0; @@ -9365,9 +9376,9 @@ bool PDFLibCore::PDF_Image(PageItem* c, const QString& fn, double sx, double sy, ShIm ImInfo2; ImInfo2.origXsc = c->imageXScale(); ImInfo2.origYsc = c->imageYScale(); - if (SharedImages.contains(fn)) - ImInfo2 = SharedImages[fn]; - if ((!SharedImages.contains(fn)) + if (SharedImages.contains(cacheID)) + ImInfo2 = SharedImages[cacheID]; + if ((!SharedImages.contains(cacheID)) || (fromAN) || (c->asLatexFrame()) || (c->effectsInUse.count() != 0) @@ -9855,10 +9866,18 @@ bool PDFLibCore::PDF_Image(PageItem* c, const QString& fn, double sx, double sy, int bytesWritten = 0; // Fixme: outType variable should be set directly in the if/else maze above. ColorSpaceEnum outType; + // Overprint does not work for images in general, but it does work + // for 1 bit images if they are drawn as image masks. + // PDF 1.3 spec, pages 197 and 257 + bool overprint1bitImage = false; if (img.imgInfo.colorspace == ColorSpaceMonochrome && c->effectsInUse.count() == 0) outType = ColorSpaceMonochrome; else outType = getOutputType(exportToGrayscale, exportToCMYK); + if(outType == ColorSpaceMonochrome + && img.imgInfo.colorspace == ColorSpaceMonochrome && + c->overprint()) + overprint1bitImage = true; if ((outType != ColorSpaceMonochrome) && (doc.HasCMS) && (Options.UseProfiles2)) { PutDoc("/ColorSpace "+ICCProfiles[profInUse].ICCArray+"\n"); @@ -9874,6 +9893,11 @@ bool PDFLibCore::PDF_Image(PageItem* c, const QString& fn, double sx, double sy, switch (outType) { case ColorSpaceMonochrome : + if (overprint1bitImage) + PutDoc("/ImageMask true\n"); + else + PutDoc("/ColorSpace /DeviceGray\n"); + break; case ColorSpaceGray : PutDoc("/ColorSpace /DeviceGray\n"); break; case ColorSpaceCMYK : PutDoc("/ColorSpace /DeviceCMYK\n"); break; default : PutDoc("/ColorSpace /DeviceRGB\n"); break; @@ -9927,22 +9951,22 @@ bool PDFLibCore::PDF_Image(PageItem* c, const QString& fn, double sx, double sy, ImInfo.ya = sy; ImInfo.RequestProps = c->pixm.imgInfo.RequestProps; } // not embedded PDF - if ((c->effectsInUse.count() == 0) && (!SharedImages.contains(fn))) - SharedImages.insert(fn, ImInfo); + if ((c->effectsInUse.count() == 0) && (!SharedImages.contains(cacheID))) + SharedImages.insert(cacheID, ImInfo); ResCount++; } else { - ImInfo = SharedImages[fn]; + ImInfo = SharedImages[cacheID]; ImInfo.sxa *= sx / ImInfo.xa; ImInfo.sya *= sy / ImInfo.ya; /* - ImRes = SharedImages[fn].ResNum; - ImWid = SharedImages[fn].Width; - ImHei = SharedImages[fn].Height; - aufl = SharedImages[fn].reso; - sxn = SharedImages[fn].sxa * sx / SharedImages[fn].xa; - syn = SharedImages[fn].sya * sy / SharedImages[fn].ya; + ImRes = SharedImages[cacheID].ResNum; + ImWid = SharedImages[cacheID].Width; + ImHei = SharedImages[cacheID].Height; + aufl = SharedImages[cacheID].reso; + sxn = SharedImages[cacheID].sxa * sx / SharedImages[cacheID].xa; + syn = SharedImages[cacheID].sya * sy / SharedImages[cacheID].ya; */ } QString embedPre = ""; -- 1.7.10.4 |
|
Attached a new patch for overprint export. It replaces the previous one. Using the same image in overprint and non-overprint works as expected. The only downside is that if a non-monochrome image is used in both overprint and regular formats, it gets written to the PDF file twice. There is no quality degradation, only a slightly bigger PDF file. This should not be an issue, because the PDF spec clearly states that overprint does not work on non-monochrome images so it's unlikely anyone is using overprint on regular images. I did not touch the color background issue as I'm not really sure what should happen. How should overprint/knockout work together with transparency and other possible image attributes. The code in this patch provides high quality 1-bit line art printing for comics, which has been my main goal. |
|
What is the fate of this patch? Currently overprinting does not work at all. This makes it work in the most common use case (though the lack of GUI preview is a very unfortunate). |
|
What is the fate of this patch? |
|
Reminder sent to: avox avox, what do you make of this? |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-09-01 18:44 | JussiP | New Issue | |
2012-09-17 18:15 | JussiP | File Added: 0001-Overprint-1-bit-images-using-ImageMasks.patch | |
2012-09-17 18:15 | JussiP | Note Added: 0028935 | |
2012-09-18 04:56 | ale | Summary | Fix overprinting for 1-bit images => [PATCH] Fix overprinting for 1-bit images |
2012-09-21 20:13 | jghali | Note Added: 0028960 | |
2012-09-24 21:43 | JussiP | Note Added: 0028971 | |
2012-09-30 14:09 | JussiP | File Added: 0001-Export-properly-formatted-overprint-images.patch | |
2012-09-30 14:17 | JussiP | Note Added: 0029005 | |
2012-11-20 14:55 | JussiP | Note Added: 0029218 | |
2014-06-11 19:38 | JLuc | Tag Attached: patch | |
2014-10-24 23:00 | Kunda | Patch | => Yes |
2015-04-11 02:17 | Kunda | Note Added: 0034874 | |
2015-04-11 20:41 | Kunda | Note Added: 0034889 | |
2015-04-15 02:30 | Kunda | Tag Attached: comics | |
2015-04-15 02:36 | Kunda | Relationship added | child of 0013013 |
2016-03-30 21:27 | Kunda | Tag Attached: overprint |