[cairo] fractional pixel placement issues with OSX backend

Travis Griggs tgriggs at cincom.com
Fri Dec 11 10:40:58 PST 2009


Something seems not quite write with pattern filling on an OSX backend.

Given a simple ImageSurface, I think it's fair to claim that the  
following two pseudo code sequences should produce the same result:

1)
source_surface( the_image_surface );
translate( x, y );
paint();

2)
pattern = create_surface_pattern( the_image_surface );
pattern_extend( repeat );
translate (x, y);
rectangle( 0, 0, the_image_surface.width, the_image_surface.height );
source( pattern );
fill();

On an OSX GCContextRef surface (for a window at least, haven't test on  
an NSImage derived one yet), this holds true _as long as x and y are  
integral_. *If* they're fractional, then they don't line up the same.  
If I use an ImageSurface as the target, then all works as expected for  
both integral and fractional positions.

I've attached two screenshots that show the problem. In both cases, it  
is the same png file used as the orignal surface. The first row is  
integral coordinates, the second row is fractional origins. The first  
column is drawing technique #1 and the second column is drawing  
technique #2.

It helps to zoom the images way up so you can see the difference. The  
imagesurface backend produces the expected results. But if you look at  
the osxbackend.png, the bottom right one (pattern drawing at a  
fractional translation), is not right. It should match the picture to  
the left, but instead it's more like the one above it. It almost seems  
in fact, that it might be OK in the y direction, but not the x  
direction.

--
Travis Griggs
Objologist
No other topic generates more heat and less light than code formatting  
--Kent Beck

-------------- next part --------------
A non-text attachment was scrubbed...
Name: imagesurface.png
Type: image/png
Size: 5119 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20091211/619189d8/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: osxbackend.png
Type: image/png
Size: 5127 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20091211/619189d8/attachment-0001.png 
-------------- next part --------------



More information about the cairo mailing list