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 Richard Knight <rc...@gmail.com> on 2007/10/17 16:05:42 UTC

Simple Rendering

I am writing an application which generates textures for objects (just
planes) in a 3d space based on an svg document.

All i need to be able to do is generate a bufferedImage of a specified
size based on the svg document and a certain scale factor.

Currently i am using code similar to this to acheive the desired
effect, with the document already loaded into a GVT graphics node:

rf = new ConcreteImageRendererFactory();
ir = rf.createStaticImageRenderer();
renderingTransform = new AffineTransform();

ir.setTree(node);
		
renderingTransform.setToIdentity();
renderingTransform.scale((float) (renderWidth / shape.width),(float)
(renderHeight /shape.height));

AffineTransform inv = null;
				
try{
	inv = renderingTransform.createInverse();
} catch (Exception e){
	System.out.println(e.getMessage());
}


Rectangle visRect = new Rectangle(0,0,callback.width,callback.height);		
		
java.awt.Shape s = inv.createTransformedShape(visRect);

r = new GVTTreeRenderer(ir,renderingTransform,false,s,(int)renderWidth,(int)renderHeight);
		
r.setPriority(GVTTreeRenderer.MIN_PRIORITY);

r.start();

Along with an appropriate GVTTreeRendererListener which simply uses
the getImage() function of the GVTTreeRendererEvent to get at the
bufferedImage i need on render completion.

This works perfectly except for one major problem, I need to render
alot of these images, and this current implementation is causing out
of memory errors in the Java VM.

The textures however are not all on screen at once, so i simply remove
all references to them when they are no longer needed In the hope that
they will be unloaded by the garbage collector to make room for the
new ones. My problem is that this does not prevent me from running out
of heap space, I assume the staticrenderer caches the images somehow?
(since re-rendering seems very fast)

I must be missing something, since i'm sure it must be possible, but
could you please outline the correct method to simply render a
graphics node, with no caching/extra hocus pocus taking place?

Thanks In Advance

Richard

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