Bug 9860 - low resolution graphic appears smoothed
Summary: low resolution graphic appears smoothed
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: cairo backend (show other bugs)
Version: unspecified
Hardware: Other All
: medium major
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-03 03:21 UTC by Carlos Garcia Campos
Modified: 2009-06-19 00:39 UTC (History)
5 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Example PDFs and screenshots from acroread and evince (550.00 KB, application/x-tar)
2008-08-12 21:43 UTC, Tom Davidson
Details
Use Interpolate flag to decide whether applying image interpolation during rendering (31.32 KB, patch)
2009-06-02 12:00 UTC, Carlos Garcia Campos
Details | Splinter Review
Use Interpolate flag to decide whether applying image interpolation during rendering (Updated) (31.43 KB, patch)
2009-06-03 05:27 UTC, Carlos Garcia Campos
Details | Splinter Review
Use Interpolate flag to decide whether applying image interpolation during rendering (38.64 KB, patch)
2009-06-12 03:10 UTC, Carlos Garcia Campos
Details | Splinter Review

Description Carlos Garcia Campos 2007-02-03 03:21:41 UTC
Forwarded from: http://bugzilla.gnome.org/show_bug.cgi?id=331781

I have a graphic showing a low resolution image with graph axes superimposed,
saved as both EPS and PDF. When I view either file with Evince, the graphic
appears smoothed. When I view the PDF with Acroread, I can see the individual
pixels.

I have uploaded three files to demonstrate the problem (the PNG shows the graph
as I want it to appear):

http://www.magres.nottingham.ac.uk/~magill/pixels/pixels.png
http://www.magres.nottingham.ac.uk/~magill/pixels/pixels.pdf
http://www.magres.nottingham.ac.uk/~magill/pixels/pixels.eps

I am using Gentoo Linux, fluxbox, evince 0.5.0, poppler-0.5.0-r5 (cairo)

Steps to reproduce:
1. open pixels.eps
2. open pixels.pdf
3. compare to pixels.png


Actual results:
The image appears as a smooth gradient.
The PDF shows a white border on the bottom and right edges of the image and
colourbar.

Expected results:
see pixels.png - I expect to see individual pixels in the image, and no white
border on the PDF. The PDF file displays as expected in Acroread. The EPS file
appears correct if displayed with xv.


I can confirm this is only reproducible with cairo backend.
Comment 1 Carlos Garcia Campos 2007-10-07 03:42:15 UTC
Another test case attached to evince bug: http://bugzilla.gnome.org/show_bug.cgi?id=484340
Comment 2 Soeren Sonnenburg 2008-01-13 08:54:43 UTC
another test case

http://bugzilla.gnome.org/show_bug.cgi?id=509132

However I noticed that while acrobat reader and xpdf render these .pdf's correctly the macosx preview viewer also has the same problem.
Comment 3 Tom Davidson 2008-08-12 21:40:38 UTC
Smoothing of low-res graphics is not always a bug. In the PDF spec (at least in version 1.7), there is a flag (called 'Interpolate') for each image which is supposed to control smoothing. It defaults to 'false', for no interpolation. 

On Fedora 8, (poppler 0.6.2.2, cairo 1.5.8, evince 2.20.2), this flag is ignored by evince, which renders all images as smoothed. Acroread (8.1.2_SU1) gets it right. 

I'm attaching 3 pdf files and screenshots showing acroread and evince with the 3 files open. 

-pixels.Imissing.pdf: Interpolate not specified (should be blocky)
-pixels.Itrue.pdf:    Interpolate=true (should be smoothed)
-pixels.Ifalse.pdf:   Interpolate=false (should be blocky)

-acroread_interp_examples.png (Acroread gets it right)
-evince_interp_examples.png (evince renders all as smoothed)
Comment 4 Tom Davidson 2008-08-12 21:43:40 UTC
Created attachment 18252 [details]
Example PDFs and screenshots from acroread and evince
Comment 5 Carlos Garcia Campos 2009-06-02 12:00:00 UTC
Created attachment 26358 [details] [review]
Use Interpolate flag to decide whether applying image interpolation during rendering

 poppler/CairoOutputDev.cc  |   92 ++++++++++++++++++++++++++------------------                                                                              
 poppler/CairoOutputDev.h   |   46 ++++++++++++---------                                                                                                     
 poppler/Gfx.cc             |   47 +++++++++++++++++++---                                                                                                    
 poppler/OutputDev.cc       |   16 +++++---                                                                                                                  
 poppler/OutputDev.h        |   12 +++--                                                                                                                     
 poppler/SplashOutputDev.cc |   15 +++++--                                                                                                                   
 poppler/SplashOutputDev.h  |   11 +++--                                                                                                                     
 utils/HtmlOutputDev.cc     |   16 ++++----                                                                                                                  
 utils/HtmlOutputDev.h      |    6 +-                                                                                                                        
 utils/ImageOutputDev.cc    |   20 +++++-----                                                                                                                
 utils/ImageOutputDev.h     |   11 +++--                                                                                                                     
 11 files changed, 183 insertions(+), 109 deletions(-)
Comment 6 Carlos Garcia Campos 2009-06-03 05:27:30 UTC
Created attachment 26390 [details] [review]
Use Interpolate flag to decide whether applying image interpolation during rendering (Updated)

 poppler/CairoOutputDev.cc  |   92 ++++++++++++++++++++++++++------------------                                                                              
 poppler/CairoOutputDev.h   |   46 ++++++++++++---------                                                                                                     
 poppler/Gfx.cc             |   47 +++++++++++++++++++---                                                                                                    
 poppler/OutputDev.cc       |   16 +++++---                                                                                                                  
 poppler/OutputDev.h        |   12 +++--                                                                                                                     
 poppler/SplashOutputDev.cc |   15 +++++--                                                                                                                   
 poppler/SplashOutputDev.h  |   11 +++--                                                                                                                     
 utils/HtmlOutputDev.cc     |   16 ++++----                                                                                                                  
 utils/HtmlOutputDev.h      |    6 +-                                                                                                                        
 utils/ImageOutputDev.cc    |   20 +++++-----                                                                                                                
 utils/ImageOutputDev.h     |   11 +++--                                                                                                                     
 11 files changed, 183 insertions(+), 109 deletions(-)

Updated after rebasing from current master.
Comment 7 Albert Astals Cid 2009-06-10 14:18:27 UTC
Some indentation is broken, eg in 

+      if (obj1.isNull()) {
+        obj1.free();
+	maskDict->lookup("I", &obj1);
+      }

of @@ -3954,6 +3979,16 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {


You forgot to change PreScanOutputDev, PSOutputDev and ArthurOutputDev functions

Adding -Woverloaded-virtual to your CXXFLAGS will help spotting this kind of errors, maybe we should add it to the default 
Comment 8 Carlos Garcia Campos 2009-06-12 03:02:18 UTC
(In reply to comment #7)
> Adding -Woverloaded-virtual to your CXXFLAGS will help spotting this kind of
> errors, maybe we should add it to the default 

Definitely

Comment 9 Carlos Garcia Campos 2009-06-12 03:10:37 UTC
Created attachment 26711 [details] [review]
Use Interpolate flag to decide whether applying image interpolation during rendering

 poppler/ArthurOutputDev.cc  |    4 +-                                                                                                                       
 poppler/ArthurOutputDev.h   |    4 +-                                                                                                                       
 poppler/CairoOutputDev.cc   |   92 +++++++++++++++++++++++++------------------                                                                              
 poppler/CairoOutputDev.h    |   46 ++++++++++++---------                                                                                                    
 poppler/Gfx.cc              |   47 +++++++++++++++++++---                                                                                                   
 poppler/OutputDev.cc        |   16 +++++---                                                                                                                 
 poppler/OutputDev.h         |   12 +++--                                                                                                                    
 poppler/PSOutputDev.cc      |    5 +-                                                                                                                       
 poppler/PSOutputDev.h       |    5 +-                                                                                                                       
 poppler/PreScanOutputDev.cc |   11 +++--                                                                                                                    
 poppler/PreScanOutputDev.h  |   11 +++--                                                                                                                    
 poppler/SplashOutputDev.cc  |   15 +++++--                                                                                                                  
 poppler/SplashOutputDev.h   |   11 +++--                                                                                                                    
 utils/HtmlOutputDev.cc      |   16 ++++----                                                                                                                 
 utils/HtmlOutputDev.h       |    6 +-                                                                                                                       
 utils/ImageOutputDev.cc     |   20 +++++-----                                                                                                               
 utils/ImageOutputDev.h      |   11 +++--                                                                                                                    
 17 files changed, 207 insertions(+), 125 deletions(-)
Comment 10 Albert Astals Cid 2009-06-18 15:41:23 UTC
drawMaskedImage in PSOutputDev still has the wrong signature

And you failed to update/set your copyright in all the touched files.

Fixing that you can commit
Comment 11 Carlos Garcia Campos 2009-06-19 00:39:52 UTC
Pushed to git master. 


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.