You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Xavier Wielemans <wi...@alterface.net> on 2002/05/08 10:44:32 UTC
JNI bridge to batik
Hi all,
Involved in a big C++ software project (virtual reality engine) I tried to
integrate batik into our system for real-time svg rendering (as it is the
only working open-source svg renderer available - to my knowledge anyway -
if you know better, PLEASE inform me, thx !).
Therefore I used JNI to bridge batik to our system. I have create an
"SVGLayer" Java class (right, the name is not very pertinent... :) It was
just a prototype...) which uses batik to load an svg document (in its
constructor) and render it inside a "scene" area, based on a given scale,
rotation, position in the scene and global scene dimensions. To do that,
it will compute the exact shape of the rendering result, in the scene coord
space (by scaling/rotating/translating the svg document's rectangular
bounding box, then clipping the resulting bounding box wrt. the scene
boundaries) and apply to that shape the inverse transform, which gives the
area to be rendered, in the svg document coord space (thanks to this, only
the effectively visible part of the svg doc will be rendered). Finally the
rendering buffer can be retrieved (dimensions and data) as an int array
(32-bit RGBA pixels) so you can use it in any other software to blend it in
your own creations, for instance.
Unfortunately for us, the performance is far from enough for our
needs. But I hope it can at least help someone else ! ;)
Here is the SVGLayer's class javadoc + the source file. If you are
interested, I can also send a C++ sample prog showing how to use it through
JNI (it works fine but it needs some extra reformatting work, so I'll do it
only if there is interest for it). The good news is that JNI data transfer
doesn't diminish overall performance that much, so it is pretty usable and
fast if you don't need a high real-time framerate. And of course you get
the excellent batik rendering quality (antialiasing etc.) !
BTW, it is not designed to support dynamic svg docs (scripting,
animations,...) so I really don't know what happens if you run it on one of
those...
Hope this helps, any comments, suggestions, critics, requests for
additional details, build scripts... welcome !
See ya,
Willy.
Xavier Wielemans - alterface
http://www.alterface.com