[gs-bugs] [Bug 690620] low resolution fill adjust is wrong

bugs.ghostscript.com-bugzilla-daemon at ghostscript.com bugs.ghostscript.com-bugzilla-daemon at ghostscript.com
Thu Jul 16 21:15:29 PDT 2009


http://bugs.ghostscript.com/show_bug.cgi?id=690620

henry.stiles at artifex.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED



------- Additional Comments From henry.stiles at artifex.com  2009-07-16 21:15 -------
The patch in #6 is improved to support center of pixel clients, pass through 0
area rectangles to high level devices, and emulate the peculiarities of Adobe
Acrobate 8 0 fills.  With the latter change the rectangles in
rectfill_frac_pixel.ps match adobe pixel for pixel at 72 dpi.  The patch has now
been regression tested against all the languages without issues.

svn diff
Index: gsdps1.c
===================================================================
--- gsdps1.c	(revision 9862)
+++ gsdps1.c	(working copy)
@@ -196,7 +196,9 @@
     bool hl_color = (hl_color_available && 
 		dev_proc(pdev, fill_rectangle_hl_color)(pdev, 
 		    	    &empty, pis, pdc, NULL) == 0);
+    bool center_of_pixel = (pgs->fill_adjust.x == 0 && pgs->fill_adjust.y == 0);
 
+    
     /* Processing a fill object operation */
     gs_set_object_tag(pgs, GS_PATH_TAG);
 
@@ -234,8 +236,14 @@
 	    draw_rect.q.y = max(p.y, q.y);
 	    if (hl_color) {
 		rect_intersect(draw_rect, clip_rect);
-		if (draw_rect.p.x < draw_rect.q.x &&
-		    draw_rect.p.y < draw_rect.q.y) {
+                /* We do pass on 0 extant rectangles to high level
+                   devices.  It isn't clear how a client and an output
+                   device should interact if one uses a center of
+                   pixel algorithm and the other uses any part of
+                   pixel.  For now we punt and just pass the high
+                   level rectangle on without adjustment. */
+		if (draw_rect.p.x <= draw_rect.q.x &&
+		    draw_rect.p.y <= draw_rect.q.y) {
 		    code = dev_proc(pdev, fill_rectangle_hl_color)(pdev,
 			     &draw_rect, pis, pdc, pcpath);
 		    if (code < 0)
@@ -243,19 +251,37 @@
 		}
 	    } else {
 		int x, y, w, h;
-
-		draw_rect.p.x -= max(pgs->fill_adjust.x - fixed_epsilon, 0);
-		draw_rect.p.y -= max(pgs->fill_adjust.y - fixed_epsilon, 0);
-		draw_rect.q.x += pgs->fill_adjust.x;
-		draw_rect.q.y += pgs->fill_adjust.y;
 		rect_intersect(draw_rect, clip_rect);
-		x = fixed2int_pixround(draw_rect.p.x);
-		y = fixed2int_pixround(draw_rect.p.y);
-		w = fixed2int_pixround(draw_rect.q.x) - x;
-		h = fixed2int_pixround(draw_rect.q.y) - y;
-		if (w > 0 && h > 0)
-    		    if (gx_fill_rectangle(x, y, w, h, pdc, pgs) < 0)
-			goto slow;
+                if (center_of_pixel) {
+                    draw_rect.p.x = fixed_rounded(draw_rect.p.x);
+                    draw_rect.p.y = fixed_rounded(draw_rect.p.y);
+                    draw_rect.q.x = fixed_rounded(draw_rect.q.x);
+                    draw_rect.q.y = fixed_rounded(draw_rect.q.y);
+                } else { /* any part of pixel rule - touched */
+                    draw_rect.p.x = fixed_floor(draw_rect.p.x);
+                    draw_rect.p.y = fixed_floor(draw_rect.p.y);
+                    draw_rect.q.x = fixed_ceiling(draw_rect.q.x);
+                    draw_rect.q.y = fixed_ceiling(draw_rect.q.y);
+                }
+		x = fixed2int(draw_rect.p.x);
+		y = fixed2int(draw_rect.p.y);
+		w = fixed2int(draw_rect.q.x - draw_rect.p.x);
+		h = fixed2int(draw_rect.q.y - draw_rect.p.y);
+                /* clients that use the "any part of pixel" rule also
+                   fill 0 areas.  This is true of current graphics
+                   library clients but not a general rule.  */
+                if (!center_of_pixel) {
+                    if (w == 0)
+                        w = 1;
+                    /* yes Adobe Acrobat 8, seems to back up the y
+                       coordinate when the width is 0, sigh. */
+                    if (h == 0) {
+                        y--;
+                        h = 1;
+                    }
+                }
+                if (gx_fill_rectangle(x, y, w, h, pdc, pgs) < 0)
+                    goto slow;
 	    }
 	}
 	return 0;




------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.



More information about the gs-bugs mailing list