Rendered image flipped when using very large scale
Hi !
I'm using librsvg to render only a specific part of a given svg. I rely on librsvg capabilities to scale it to a target size.
Here is the pseudo code i'm using :
handle = rsvh_handle_new_from_data(svg, svg.length, *error);
surface = cairo_image_surface_create(CairoFormat.Argb32, 100, 100);
cairo = cairo_create(surface);
rsvg_handle_render_document(handle, context, viewport, *error);
cairo_surface_flush(surface);
data = cairo_image_surface_get_data(surface);
So basicaly I load the svg and then render it in a cairo surface of 100x100 px. I then display the produced image in my application.
On a basic usage, everything works fine, but let's play with very big scales...
My source svg is a simple square of 100x100 units with 4 coloured squared inside, the top left square is red and the bottom right is green (very important !) :
To render it I define a viewport with the following values :
x = 0,
y = 0,
width = 1000000
height = 1000000
librsvg will draw an object 1,000,000px wide in my canvas, so 10,000 times larger than the original one. Since my surface is 100px wide I will see a big red square (the very top left on the whole image). Until here everything's fine.
But if I try with a viewport of 10,000,000 the resulting image will be flipped (or mirrored), now the square is green (I made a lot of test the image is actually flipped over) :
Then if I go with a viewport of 100,000,000 or 1,000,000,000 the resulting image is just not rendered at all (I got a transparent image) :
Here comes the funiest part, if I then use a viewport of 10,000,000,000 everything works fine !
I suspect a sign problem either in librsvg or in cairo when applying scale/transforms.
The problem exists in 2.46 and in previous versions too.
It seems wierd to play with such massives scales but it is the case for us (dealing with very high precision svgs).
Thanks for your help