Page 1 of 1

viewBox x and y not used at converting svg to png

Posted: 2011-12-01T07:06:15-07:00
by Alex Dobusch
Hello

I'm using the latest subversion trunk (rev. 6100).

In my svg file I declared a viewBox with x and y coordinates, like 'viewBox="50 50 150 150"'.
It seems that these coordinates were not used to convert the svg, only the width and height of the viewBox.
After debugging the code I found the solution in the file 'coders\svg.c'
At line 2167 change

Code: Select all

          double
            sx,
            sy;
to

Code: Select all

          double
            sx,
            sy,
            tx,
            ty;
and at line 2180 change

Code: Select all

          (void) FormatLocaleFile(svg_info->file,"affine %g 0 0 %g 0.0 0.0\n",
            sx,sy);
to

Code: Select all

          tx= svg_info->view_box.x != 0.0 ? (double) sx*-svg_info->view_box.x : 0.0;
          ty= svg_info->view_box.y != 0.0 ? (double) sy*-svg_info->view_box.y : 0.0;
          (void) FormatLocaleFile(svg_info->file,"affine %g 0 0 %g %g %g\n",
            sx,sy,tx,ty);
Now it uses the x and y coordinates from the viewBox.

Alex

Re: viewBox x and y not used at converting svg to png

Posted: 2011-12-01T08:59:22-07:00
by magick
Thanks for the problem report and patch. We'll get it into the subversion trunk by sometime tomorrow.