[gs-cvs] rev 8241 - trunk/gs/lib

leonardo at ghostscript.com leonardo at ghostscript.com
Tue Sep 18 08:33:51 PDT 2007


Author: leonardo
Date: 2007-09-18 08:33:51 -0700 (Tue, 18 Sep 2007)
New Revision: 8241

Modified:
   trunk/gs/lib/gs_img.ps
Log:
Fix : The interpolation of imagemask must not apply to high resolution images.

DETAILS :

Bug 689249 "Major performance degradation rendering PDF",

The revision 7123 implements a conversion of imagemask 
into a bigger image with a smoother pixel granularity. 
Actually the conversion isn't useful for high resolution images
which map an image pixel into a small number of device pixels.
This patch implements such check and it apparently helps for pdfwrite.

Note it includes an arbitrary threshold,
which may need further adjustment.
See comment in code.

EXPECTED DIFFERENCES :

A minor difference with pdfwrite :

149-01.ps
Bug687290.ps


Modified: trunk/gs/lib/gs_img.ps
===================================================================
--- trunk/gs/lib/gs_img.ps	2007-09-14 10:17:07 UTC (rev 8240)
+++ trunk/gs/lib/gs_img.ps	2007-09-18 15:33:51 UTC (rev 8241)
@@ -674,7 +674,22 @@
   }
 .bind systemdict begin odef end
 
+% An auxiliary function for checking whether an imagemask to be interpolated.
+/.is_low_resolution    %  <image dict> .is_big_zooming <bool>
+{  % Checking whether image pixel maps to more than 2 device pixels.
+   % The threshold 2 is arbitrary.
+   1 exch 0 exch
+   0 exch 1 exch
+   /ImageMatrix get dup
+   2 {
+     4 1 roll
+     idtransform dtransform dup mul exch dup mul add sqrt
+   } repeat
+   max
+   2 gt % arbitrary
+} .bind def
 
+
 %
 %   width  height  polarity  matrix  datasrc   imagemask   -
 %
@@ -686,7 +701,8 @@
     dup type /dicttype eq .languagelevel 2 ge and
       { dup /ImageType get
         //.imagemasktypes exch .knownget
-          { 1 index /ImageType get 1 eq
+          { 1 index //.is_low_resolution exec
+            2 index /ImageType get 1 eq and
 	    2 index /BitsPerComponent get 1 eq and
 	    2 index /Interpolate .knownget not { false } if and
 	    //filterdict /ImscaleDecode known and {



More information about the gs-cvs mailing list