Hi,
i'm having some problems trying to create JPEG/TIFF/PNG-images from an
svggraphics2d element in memory.
I used to write an svg file to the file system and then read it in again to
transcode it, but that's a bit messy.
Can anyone help me?
Thanks in advance,
Brecht
private static void transcode(Visualisation vis, File file, ImageTranscoder
t, Dimension dim) throws IOException {
DOMImplementation domImpl =
GenericDOMImplementation.getDOMImplementation();
Document document = domImpl.createDocument(null, "svg", null);
SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(document);
ctx.setComment("Generated by Trs-visualisation");
SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx, false);
svgGenerator.setSVGCanvasSize(dim);
vis.render(svgGenerator, new Double(dim.getWidth()).intValue(), new
Double(dim.getHeight()).intValue(), null);
PipedReader sink = new PipedReader();
PipedWriter source = new PipedWriter(sink);
svgGenerator.stream(source);
TranscoderInput input = new TranscoderInput(sink);
OutputStream ostream = null;
try {
ostream = new FileOutputStream(file);
} catch (FileNotFoundException e3) {
logger.error(e3);
}
TranscoderOutput output = new TranscoderOutput(ostream);
try {
t.transcode(input, output);
} catch (TranscoderException e1) {
logger.error(e1);
}
ostream.flush();
ostream.close();
new File("temp.svg").delete();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]