[gs-cvs] rev 7783 - in trunk/gs: doc src

leonardo at ghostscript.com leonardo at ghostscript.com
Tue Mar 13 15:35:52 PDT 2007


Author: leonardo
Date: 2007-03-13 15:35:51 -0700 (Tue, 13 Mar 2007)
New Revision: 7783

Modified:
   trunk/gs/doc/pscet_status.txt
   trunk/gs/src/gxstroke.c
Log:
Fix (stroking) : Apply the right math for computing always_thin,

DETAILS :

The old code estimated the line width with 
an empiric formula, which doesn't look well defined.
Replacing it with a right math.
See comment in code.

EXPECTED DIFFERENCES :

comparefiles/Bug688789.pdf - a minor single pixel difference at 300 dpi.

CET - None.


Modified: trunk/gs/doc/pscet_status.txt
===================================================================
--- trunk/gs/doc/pscet_status.txt	2007-03-11 20:47:13 UTC (rev 7782)
+++ trunk/gs/doc/pscet_status.txt	2007-03-13 22:35:51 UTC (rev 7783)
@@ -1700,22 +1700,13 @@
 
 11-09-3  OK	
 
-11-09-4  DIFF	linewidth different.
+11-09-4  AOK	linewidth different.
                 Analyzed by Igor.
 		GS paints a "thin line" whenever the line wdth is lesser than 1 pixel.
 		The decision is taken in gxstroke.c ln 453, 468, 482
 		with the threshold half width smaller than half pixel.
 		Well I can set a smaller threshold for CPSI compatibility,
 		but I need CPSI to measure its constant.
-		-
-		BTW, gxstroke.c ln 483 looks BUGGY :
-		what does 'cross' do here ????
-		The matrix [1 -1 -1 1 0 0] gixes cross = -2 and 
-		always_thin = ((max(2,2) + -2) * somrthing < 0.25) = true /* WRONG !!!!!! */
-		IMO cross to be removed at all.
-		(this bug is unrelated to CET test).
-		-
-                assign: Igor.
 
 11-09-5  OK	Minor differences visually reviewed by RJJ
 

Modified: trunk/gs/src/gxstroke.c
===================================================================
--- trunk/gs/src/gxstroke.c	2007-03-11 20:47:13 UTC (rev 7782)
+++ trunk/gs/src/gxstroke.c	2007-03-13 22:35:51 UTC (rev 7783)
@@ -479,15 +479,23 @@
 	    default:
 		{
 		    /* The check is more complicated, but it's worth it. */
-		    double xsq = xx * xx + xy * xy;
-		    double ysq = yx * yx + yy * yy;
-		    double cross = xx * yx + xy * yy;
-
-		    if (cross < 0)
-			cross = 0;
-		    always_thin =
-			((max(xsq, ysq) + cross) * line_width * line_width
-			 < 0.25);
+		    /* Compute radii of the transformed round brush. */
+		    /* Let x = [a, sqrt(1-a^2)]' 
+		       radius^2 is an extremum of :
+		       rr(a)=(CTM*x)^2 = (a*xx + sqrt(1 - a^2)*xy)^2 + (a*yx + sqrt(1 - a^2)*yy)^2
+		       With solving D(rr(a),a)==0, got :
+		       max_rr = (xx^2 + xy^2 + yx^2 + yy^2 + sqrt(((xy + yx)^2 + (xx - yy)^2)*((xy - yx)^2 + (xx + yy)^2)))/2.
+		       r = sqrt(max_rr);
+		       Well we could use eigenvaluse of the quadratic form,
+		       but it gives same result with a bigger calculus.
+		     */
+		    double max_rr = (xx*xx + xy*xy + yx*yx + yy*yy + 
+					sqrt( ((xy + yx)*(xy + yx) + (xx - yy)*(xx - yy)) * 
+					      ((xy - yx)*(xy - yx) + (xx + yy)*(xx + yy)) 
+					    )
+				     )/2;
+		    
+		    always_thin = max_rr * line_width * line_width < 0.25;
 		}
 	}
     }



More information about the gs-cvs mailing list