[gs-cvs] rev 8694 - trunk/gs/src

leonardo at ghostscript.com leonardo at ghostscript.com
Fri May 2 13:13:50 PDT 2008


Author: leonardo
Date: 2008-05-02 13:13:50 -0700 (Fri, 02 May 2008)
New Revision: 8694

Modified:
   trunk/gs/src/gxp1fill.c
Log:
Fix (graphics) : Imprecise pattern phase with negative cell origins.

DETAILS :

The old code inaccurately converts floats to integers.
The problem here is that (int)-0.13 == 0 but the math wants -1.
It causes a 1 pixel bias with negative coordinates when argument is not integer.
This isn't a first time when we fix a bug of this kind,
and likely this one is not the last.

This change is important for bug 689579.
Here is a test for debugging it :

<<
  /PaintType 1
  /PatternType 1
  /TilingType 1
  /BBox [0 0 60 60]
  /XStep 40
  /YStep 60
  /star
  { gsave
    0 12 moveto
    4
    { 144 rotate
      0 12 lineto
    } repeat
    closepath
    fill
    grestore
  }
  /PaintProc
  { begin
    1 0 0 setrgbcolor
    15 15 translate
    star
    0 0 1 setrgbcolor
    30 30 translate
    star
    0 1 0 setrgbcolor
    -30 0 translate
    star
    30 -30 translate
    star
    end
    %.break
  } 
>>
[1 0 0 1 0 0]
makepattern
/Star4 exch def

/Pattern setcolorspace
Star4 setcolor

clippath pathbbox 
exch pop 30 exch
4 copy = = = =
rectfill

showpage

The old code gives different rasters for this test while banded and unbanded rendering.

EXPECTED DIFFERENCES :

Bug688396.pdf
269-01.ps


Modified: trunk/gs/src/gxp1fill.c
===================================================================
--- trunk/gs/src/gxp1fill.c	2008-05-02 08:07:50 UTC (rev 8693)
+++ trunk/gs/src/gxp1fill.c	2008-05-02 20:13:50 UTC (rev 8694)
@@ -149,9 +149,9 @@
     if_debug4('T', "[T]i=(%d,%d) j=(%d,%d)\n", i0, i1, j0, j1);
     for (i = i0; i < i1; i++)
 	for (j = j0; j < j1; j++) {
-	    int x = (int)(step_matrix.xx * i +
+	    int x = (int)floor(step_matrix.xx * i +
 			  step_matrix.yx * j + step_matrix.tx);
-	    int y = (int)(step_matrix.xy * i +
+	    int y = (int)floor(step_matrix.xy * i +
 			  step_matrix.yy * j + step_matrix.ty);
 	    int w = tbits_or_tmask->size.x;
 	    int h = tbits_or_tmask->size.y;



More information about the gs-cvs mailing list