[gs-bugs] [Bug 691034] New: "Inverted" page devices have the wrong ctm

bugs.ghostscript.com-bugzilla-daemon at ghostscript.com bugs.ghostscript.com-bugzilla-daemon at ghostscript.com
Thu Dec 31 14:02:21 UTC 2009


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

           Summary: "Inverted" page devices have the wrong ctm
           Product: Ghostscript
           Version: HEAD
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P4
         Component: Graphics Library
        AssignedTo: robin at wss.co.uk
        ReportedBy: robin at wss.co.uk
         QAContact: gs-bugs at ghostscript.com


This bug describes a problem noted when investigating bug 689222. I have a 
solution to it, but it's a change that will have wide ranging (but hopefully 
minor) impact on all rendering, so it's worth describing separately in detail 
and soliciting opinions on the best way to test it.

All the bitmap output devices I have tested in ghostscript (with the exception 
of the display device under windows) use a "vertically flipped" page matrix 
(henceforth referred to as "inverted"). This means they are typically of the 
form:

 [scale_factor 0 0 -scale_factor 0 page_height]

The windows display device, by contrast uses:

 [scale_factor 0 0 scale_factor 0 0]

I claim that the bitmap devices are wrong, and should be using:

 [scale_factor 0 0 -scale_factor 0 0 page_height-(1/256)]

Consider a page of page_width x page_height pixels. Ghostscript treats every 
pixel as a half open region that includes the points on it's left/bottom edge 
and excludes those on the top/right edges. Thus point (x,y) falls into pixel 
(floor(x), floor(y)).

(0,0) is therefore inside pixel (0,0) and is as low as a point can go and 
still be on the page.

(0, page_height) is therefore inside pixel (0, page_height) and is as low as 
you can go and be just off the top of the page.

Under the 'inverted' CTM, (0,0) maps to (0,page_height) (now off the page), 
and (0, page_height) maps to (0,0) (now on the page).

Thus there is a definite change in which points are on/off the page under the 
inverted transform.

More generally, under the inverted transform, a half open pixel region will 
change the nature of it's half-openness, rather than including the bottom and 
excluding the top edges, the image under transformation will exclude the 
bottom, and include the top edge.

The solution to this is to offset the vertical swap by the smallest possible 
amount. Given that we work in 8 bit fixed accuracy internally, this means 
1/256.



------- 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