Bug 22473 - Need to handle the Matte entry
Summary: Need to handle the Matte entry
Status: RESOLVED MOVED
Alias: None
Product: poppler
Classification: Unclassified
Component: cairo backend (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
: 94132 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-06-25 06:38 UTC by william
Modified: 2018-08-20 21:47 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
This is a screen capture to show the difference. (725.25 KB, image/png)
2009-06-25 06:38 UTC, william
Details
problem pdf (887.46 KB, application/pdf)
2009-06-25 12:34 UTC, william
Details
Implementation of matte entries in softmasks of softmasked images (8.25 KB, patch)
2016-02-18 15:44 UTC, Thomas Freitag
Details | Splinter Review
Implementation of matte entries in softmasks of softmasked images (8.67 KB, patch)
2016-02-24 11:21 UTC, Thomas Freitag
Details | Splinter Review
Implementation of matte entries in softmasks of softmasked images (8.73 KB, patch)
2016-02-25 13:39 UTC, Thomas Freitag
Details | Splinter Review
Implementation of matte entries in softmasks of softmasked images (8.86 KB, patch)
2016-02-29 13:45 UTC, Thomas Freitag
Details | Splinter Review
Implementation of matte entries in softmasks of softmasked images (9.02 KB, patch)
2016-03-01 16:21 UTC, Thomas Freitag
Details | Splinter Review

Description william 2009-06-25 06:38:18 UTC
Created attachment 27132 [details]
This is a screen capture to show the difference.

I was building a website based on a design from a PDF. I got the pdf in my
email, opened it up, and built the site. Then I looked at it on windows, and
noticed that the colors in the PDF were way off. I am attaching a screenshot of
evince and adobe reader, both on linux, side by side.
Comment 1 Albert Astals Cid 2009-06-25 11:17:19 UTC
Any chance we can get the pdf file?
Comment 2 william 2009-06-25 12:34:17 UTC
Created attachment 27141 [details]
problem pdf
Comment 3 Albert Astals Cid 2009-06-25 13:26:06 UTC
Renaming the bug, the problem is we don't handle the Matte entry
Comment 4 Jason Crain 2016-02-13 21:53:36 UTC
*** Bug 94132 has been marked as a duplicate of this bug. ***
Comment 5 Thomas Freitag 2016-02-18 15:44:19 UTC
Created attachment 121832 [details] [review]
Implementation of matte entries in softmasks of softmasked images

This patch implements it for splash :-D
Comment 6 Albert Astals Cid 2016-02-18 21:42:57 UTC
I think that in 

for (int cp = 0; cp < nComps; cp++) {
        q[cp] = (*p) ? imgData->matteColor[cp] + (q[cp] - imgData->matteColor[cp]) * 255 / *p : q[cp];
      }

nComps should be destComps instead of nComps, otherwise on splashModeXBGR8 i get all kind of weird vertical artifacts.
Comment 7 Thomas Freitag 2016-02-24 11:21:41 UTC
Created attachment 121945 [details] [review]
Implementation of matte entries in softmasks of softmasked images

Here the correction to handle splashModeXBGR8 correct.
Comment 8 Thomas Freitag 2016-02-24 14:06:56 UTC
BTW, I made the same mistake as You when I first read the formula in the PDF spec:

c′ = m + α * (c - m)

where

c′ is the value to be provided in the image source data
c is the original image component value
m is the matte colour component value
α is the corresponding mask sample

I also thought first that we have to calulate c′, but that is what is provided by the image source data!!! We have to calculate c!!

<==>

c = m + (c′ - m) /  α 

And then we have to keep in mind that α is the opacity with value between 0..1, and since the mask has value between 0..255 we have to divide the mask sample by 255 or multiply with the inverse.
This does the trick.
Comment 9 Albert Astals Cid 2016-02-24 23:00:13 UTC
Still doesn't fix splashModeXBGR8 for me, see http://i.imgur.com/VSVjeyE.png
Comment 10 Thomas Freitag 2016-02-25 13:39:44 UTC
Created attachment 121959 [details] [review]
Implementation of matte entries in softmasks of softmasked images

Need to run over splashColorModeNComps, not over numComps of image, image is already converted to splash colorMode!
Comment 11 Thomas Freitag 2016-02-25 13:43:02 UTC
(In reply to Albert Astals Cid from comment #9)
> Still doesn't fix splashModeXBGR8 for me, see http://i.imgur.com/VSVjeyE.png

Sorry, Albert. The loop was completely wrong, not only for splashModeXBGR8. It just worked in the regression test because image colorspace RGB fits to splash colorspace.

BTW, I think I already asked long time ago, but I forgot: how do You test the splashModeXBGR8???
Comment 12 Albert Astals Cid 2016-02-25 21:45:25 UTC
(In reply to Thomas Freitag from comment #11)
> BTW, I think I already asked long time ago, but I forgot: how do You test
> the splashModeXBGR8???

I don't have autotests, i just run the file manually with qt4/test/test-poppler-qt4
Comment 13 Albert Astals Cid 2016-02-27 11:32:29 UTC
Can you have a look at https://bugsfiles.kde.org/attachment.cgi?id=9140 ?

I have the feeling the yellow boxes are a bit "too yellow" if compared to the rendering of Adobe Reader.
Comment 14 Thomas Freitag 2016-02-29 13:45:59 UTC
Created attachment 122027 [details] [review]
Implementation of matte entries in softmasks of softmasked images

This patch fixes the yellow color from regression from comment 13
Comment 15 Albert Astals Cid 2016-02-29 22:35:43 UTC
Why do we ignore strDCT ?
Comment 16 Thomas Freitag 2016-03-01 16:19:58 UTC
(In reply to Albert Astals Cid from comment #15)
> Why do we ignore strDCT ?

Sorry, my mistake: when I started to look deeper in the results of my regression tests I encountered that I got huge problems with beamerexample1.pdf, there I got "dancing colors". And I thought that the reason was that the formula often runs into the clipping of pixels which sometimes "random" values. I thought that the reason was the usage of this lossy compression, and ignore this in a first step. After I got all other samples running I forgot that and upload the patch before thinking again about it....

But today I wasn't no more satisfied with that explanation and searched and searched what the reason could be, and I was just one step away to give completely up, but finally I now found the reason: 

In the PDF of comment 13 AND in the beamerexample1.pdf the alpha values were inverted (Decode [1 0]!!), and instead of use this for the matte color I have to correct the alpha value in the formula!
Comment 17 Thomas Freitag 2016-03-01 16:21:10 UTC
Created attachment 122062 [details] [review]
Implementation of matte entries in softmasks of softmasked images

Sorry for any inconvenience, but may You have again a look at this patch. It seems, as if it solves all our issues.
Comment 18 Albert Astals Cid 2016-03-02 08:52:45 UTC
Pushed Thomas' patch, moving to cairo backend bug now.
Comment 19 GitLab Migration User 2018-08-20 21:47:42 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/poppler/poppler/issues/73.


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.