Bug 5079

Summary: Transformation matrix gives wrong results for Postscript backend
Product: cairo Reporter: Michael Wimmer <mike.wimmer>
Component: postscript backendAssignee: Carl Worth <cworth>
Status: RESOLVED FIXED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: normal    
Priority: high    
Version: 1.1.1   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Test program
Output of cairotest.c using transformation matrix
Output of cairotest.c without using transformation matrix

Description Michael Wimmer 2005-11-18 00:28:48 UTC
I've got some problems using the Postscript backend of cairo. 
I guess it's a bug but it could just as well be my limited understanding
of cairo ...

So here's the problem:

The following code snippet should produce a line from the lower left corner
to the upper right corner of the picture:
------------------------------------------------------
  cairo_surface_t *surface=cairo_ps_surface_create("test.ps",200,200);
  cairo_t *cr=cairo_create(surface);

  cairo_matrix_t matrix;

  matrix.xx=1.0;
  matrix.xy=0.0;
  matrix.yx=0.0;
  matrix.yy=-1.0;
  
  matrix.x0=0.0;
  matrix.y0=200;

  cairo_set_matrix(cr,&matrix);

  cairo_move_to(cr,0,0);
  cairo_line_to(cr,200,200);
  cairo_stroke(cr);

  cairo_show_page(cr);
  cairo_destroy(cr);
  cairo_surface_destroy(surface);
----------------------------------------------------
it should actually be equivalent to
---------------------------------------------------
  cairo_move_to(cr,0,200);
  cairo_line_to(cr,200,0);
  cairo_stroke(cr);
----------------------------------------------------

These code snippets do produce the same result for the Xlib
and pdf backends, for the ps backend, the first snippet creates
a diagonal line that is shifted to the left, out of the bounding box,
so that it's only visible in the upper left corner. The second snippet 
gives the correct result. 
This was tested using the latest cairo version from cvs today (11/17/05)
which is 1.1.1, I think.

Kind regards,

Mike Wimmer
Comment 1 Michael Wimmer 2005-11-18 00:34:05 UTC
Created attachment 3827 [details]
Test program

Code to test the Bug. Using the PS backend of cairo, it draws a diagonal line
from the lower left corner to the upper right corner of the picture, first
using
a transformation matrix and the directly. It creates two ps-files:
"test1.ps" (using the transformation matrix) and "test2.ps" without the
transformation matrix.
Comment 2 Michael Wimmer 2005-11-18 00:35:43 UTC
Created attachment 3828 [details]
Output of cairotest.c using transformation matrix

ps-file, output created with transformation matrix. The diagonal line is
shifted to the left, out of the bounding box.
Comment 3 Michael Wimmer 2005-11-18 00:37:25 UTC
Created attachment 3829 [details]
Output of cairotest.c without using transformation matrix

ps-output without using a transformation matrix. The coordinates have been
calculated manually and the ps-file shows a diagonal line as expected.
Comment 4 Behdad Esfahbod 2006-06-29 08:40:55 UTC
Just tested.  Fixed already.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.