xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Bunn <...@basen.net>
Subject Re: Is there a light-weight way of rendering multiple SVG -> single Graphics2D?
Date Fri, 15 Sep 2006 11:56:58 GMT

On Sep 14, 2006, at 19:17 , Pieter Jansen wrote:
>
> The "JSVG" class in 'contrib' of the batik source distribution might
> give you some ideas. Thomas created a very easy way to rasterize SVG
> documents using their URL (in different frames, but that code should
> be easy to adjust)

Pieter -
thanks. I followed the sources, and based on the renderers and  
transcoders
managed to get things working. It may not be optimal, but works at  
least for the prototype stage.

In case someone else needs a summary, or anyone has suggestions for  
improvements, here's what I ended up with.
I'm doing no transformations, and assume the svg behaves nicely, fits  
into my content area, etc.

            UserAgent ua = new UserAgentAdapter();
            BridgeContext bc = new BridgeContext( ua );
            GVTBuilder builder = new GVTBuilder();
            GraphicsNode gvtRoot = builder.build( bc, mySVGDocument );
            ImageRenderer renderer =  
m_rendFactory.createStaticImageRenderer();
            renderer.updateOffScreen( m_width, m_height );
            renderer.setTransform( new AffineTransform() );
            renderer.setTree( gvtRoot );
            renderer.setDoubleBuffered( false );
            Shape area = new Rectangle( 0, 0, m_width, m_height );
            renderer.repaint( area );
            BufferedImage rend = renderer.getOffScreen();
            myGraphics2D.drawRenderedImage( rend, null );
            renderer.dispose();

I'm still a bit worried about performance - there's a possibility I  
need to draw hundreds, if not thousands, of SVG DOM representations  
into a large image. (There will be just one DOM, which I clone,  
modify the clone with JXPath, render, repeat.) Haven't done any  
timing yet, though, and won't worry about it until it's nice and loomy.

Thanks;
//ebu


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


Mime
View raw message