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 Thomas DeWeese <Th...@Kodak.com> on 2005/07/01 13:54:32 UTC

Re: svg image file loading time problem

Hi Chandra,

chandra srinivasan wrote:

> See attached svg image file. when I load it in squiggle (batik 1.6) it 
> takes over a minute to render. most of the time is used for creating the 
> GVT tree. but when I open it using IE with ASV it takes maximum of 6-7 
> seconds to render. Why?

    I'm very surprised to hear your numbers.  For me it takes
100ms to read the XML, 40ms to build the document, and 201ms to
render it - total time is less than half a second.  If you are timing
from application start this isn't a very good measure as, first
Java is very slow getting started and second it need to get information
from the system on things like available fonts.

> Now in my swing app I load the main svg file (which has the attached 
> file as an image element) onto JSVGCanvas. I also create a buffered 
> image for the attached image file before I render it onto svgcanvas. I 
> create the buffered image by creating a gvt tree, using staticrenderer. 
> I create a buffered image so that I can set my cursor image to the 
> buffered image for drag and drop operations on the svg image. Now the 
> main svg file loads and renders quite quickly but the process of 
> creating a buffered image takes a long time( equal to the time squiggle 
> takes in building the gvt tree for attached image).

    As I said this did not take very long for me.  What system are
you running on? (JVM, Host OS, Batik version)

> my question here is
> 
> 1) when you attach an svg image to another svg file and render it, is 
> the gvt tree not created for the image?

    The GVT tree is created for the referenced image.  If you want
to dig in you can get the GraphicsNode for the image element.  From
there you can get the RootGraphicsNode of the image element.  You
should be able to construct a BufferedImage and paint that
referenced SVG image's GVT tree to the buffered image.

> 2) is there anyway I can get a buffered image for a svg image file 
> without building the GVT tree? are there any shortcuts?

     No, and not really.  The GVT is what we render from, without
a GVT tree there will be no rendering.  As far as shortcuts
there is a slight possibility that loading the image 'static'
would speed things up but probably not.  One thing that occurs
to me would be to 'pre-render' these to small PNG's and you could
fetch them instead of the SVG... Although If you grab the render
tree from the main document it will probably be more than fast
enough at creating the BufferedImage for simple images like your
example.

     I will comment that the file in question has a lot of 'junk' in
it.  There is an embedded font (which is probably Adobe's wacky
CEF font format), there appears to be an embedded thumbnail of
the image (which you could potentially pull out).  I would be
tempted to use XSLT to strip out anything not in the SVG namespace
(you might have to be a little careful with the embedded switch
elements).  The resulting file would be tiny compared to the
current file.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org