Bug 80719

Summary: pdftocairo -svg renders a jpeg image with inverted color
Product: poppler Reporter: Duan Yao <duanyao>
Component: cairo backendAssignee: poppler-bugs <poppler-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: adyer
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: PDF file contains a jpeg image in DeviceN colorspace
the output of pdftocairo -svg, color is inverted
only embed mime data for gray/rgb/cmyk colorspaces
only embed mime data for gray/rgb/cmyk colorspaces
only embed mime data if decode map is identity
only embed mime data if decode map is identity

Description Duan Yao 2014-06-30 15:56:57 UTC
Created attachment 102020 [details]
PDF file contains a jpeg image in DeviceN colorspace

The attached PDF file contains a jpeg image in DeviceN colorspace, whose alternate colorspace is DeviceRGB.

After converted to svg, the image's displayed color is inverted, i.e. white becomes black, and black becomes white.

Other output format like png looks correct.

I build poppler from 8a5e59c6ea7ccd0ecbdb4b37bf3fe4e74e1c0e8e.
Comment 1 Duan Yao 2014-06-30 15:58:33 UTC
Created attachment 102021 [details]
the output of pdftocairo -svg, color is inverted
Comment 2 David Hedley 2014-09-23 14:41:55 UTC

*** This bug has been marked as a duplicate of bug 68965 ***
Comment 3 Adrian Johnson 2014-09-24 11:54:27 UTC
Created attachment 106787 [details] [review]
only embed mime data for gray/rgb/cmyk colorspaces
Comment 4 Adrian Johnson 2014-09-24 23:00:12 UTC
Created attachment 106818 [details] [review]
only embed mime data for gray/rgb/cmyk colorspaces

Update to fix a leak.
Comment 5 Adrian Johnson 2014-10-06 00:02:11 UTC
Created attachment 107384 [details] [review]
only embed mime data if decode map is  identity

This patch fixes another issue with setMimeData(). The mime data should not be embedded if the decode map is anything other than [0 1 0 1 ... ]
Comment 6 Carlos Garcia Campos 2014-10-06 16:32:07 UTC
Comment on attachment 107384 [details] [review]
only embed mime data if decode map is  identity

Review of attachment 107384 [details] [review]:
-----------------------------------------------------------------

::: poppler/CairoOutputDev.cc
@@ +2719,5 @@
> +  // only embed mime data if image decode map is identiy
> +  for (i = 0; i < colorMap->getNumPixelComps(); i++) {
> +    if (colorMap->getDecodeLow(i) != 0.0 || colorMap->getDecodeHigh(i) != 1.0)
> +      return;
> +  }

Looks good, maybe we could add a helper method for this, and we don't need the comment to explain it. something like:

if (!colorMapHasIdentityDecodeMap(colorMap))
  return;

Or something similar.
Comment 7 Adrian Johnson 2014-10-07 10:14:35 UTC
Created attachment 107470 [details] [review]
only embed mime data if decode map is identity
Comment 8 Carlos Garcia Campos 2014-10-07 16:07:09 UTC
Comment on attachment 107470 [details] [review]
only embed mime data if decode map is identity

Review of attachment 107470 [details] [review]:
-----------------------------------------------------------------

Perfect, thanks!
Comment 9 Adrian Johnson 2014-10-07 20:17:06 UTC
Pushed.
Comment 10 Adrian Johnson 2015-11-20 08:36:18 UTC
*** Bug 93031 has been marked as a duplicate of this bug. ***

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.