You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by th...@kodak.com on 2008/02/06 02:52:35 UTC
Re: Rendered image vs. canvas size
Hi Andrej,
"Andrej T." <ta...@gmail.com> wrote on 01/18/2008 10:48:03 AM:
> say I put a JSVGScrollPane in a JFrame and load a SVG image via the
> canvas.setURI(...), then the image is
> automatically resized to fit the Scrollpane size.
>
> Question:
> * if i resize the JFrame, the canvas is automatically resized to the new
> dimensions, but the rendered image is not (of course, it's on a scroll
> pane). How do i get the size of the rendered image?
This is actually a complex question and depends on the setting
of viewBox and width/height attributes on the root SVG element.
The simplest answer is to simply get the bbox of the root svg element.
However this can be "wrong" when a viewBox is used to clip content.
The more correct way would be to map the viewBox (or 0,0 width,height
if no viewBox is provided) through the viewing transform.
> One more thing. If I dont use a scrollpane and put JSVGCanvas directly
on a
> panel, on panel resize the canvas and the displayed image are
automatically
> resized preserving the aspect ration. In the svg file no
> preserve-aspectratio attributs are set.
This means the default value of 'xMidYMid Meet' is used.
> Question:
> * is there a way such that the rendered image perfectly fits the canvas
size
> (not preserving tha aspect ratio)?
Set preserveAspectRatio="none" on the root SVG element. You also need
a viewBox as well.