On 9/21/07, Leonardo Kenji Shikida <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> I am trying to generate tiled Jpegs from my SVG but it's generating blank
> images
>
> My assumption is that
>
> Document doc = domImpl.createDocument(svgNS, "svg", null);
> SVGGraphics2D svg = new SVGGraphics2D(doc);
>
> actually means that, when the app draws something in the graphical
> context (svg), actually, nodes are being added to the SVG DOM
> representation (doc)
>
> but when I try to generate JPEGs from the DOM, all I've got are blank
> tiles, while the SVG generation works well.
>
> what am I doing wrong? (please check the code, I've left some comments
> there)
>
> by the way, just another questions
>
> - Is there a way to save my SVG as a PDF document?



Yes. Just use the PDFTranscoder (very similar to other transcoders).




- My SVG can become quite large, so I am afraid a in-memory DOM will
> give me a OutOfMemory exception. Is there any workaroud? Like some
> sort of file-based structure that can bypass the JVM 32-bit limitation
> of addressing about up to (almost) 2 GB in the heap? What's the usual
> approach for this?



That is interesting but the only solution I know is  tuning the JVM with the
Xmx , Xms, ... options.



my code looks like this
>
> //create DOM
>
>         DOMImplementation domImpl =
>             GenericDOMImplementation.getDOMImplementation();
>         String svgNS = "http://www.w3.org/2000/svg";;
>         Document doc = domImpl.createDocument(svgNS, "svg", null);
>
>         SVGGraphics2D svg = new SVGGraphics2D(doc);
>
> //paint something in the graphical context
>         paintComponent(svg);
>
>         SaveAsJPEGTiles p = new SaveAsJPEGTiles();
>         int dw2 = documentWidth / 2;
>         int dh2 = documentHeight / 2;
>
> //generate 4 JPEG tiles - these tiles are being generated with the
> right size, but all blank. why?
>
>         p.tile(doc, "/tmp/tileTopLeft.jpg", new Rectangle(0, 0, dw2,
> dh2));
>         p.tile(doc, "/tmp/tileTopRight.jpg", new Rectangle(dw2, 0, dw2,
> dh2));
>         p.tile(doc, "/tmp/tileBottomLeft.jpg", new Rectangle(0, dh2, dw2,
> dh2));
>         p.tile(doc, "/tmp/tileBottomRight.jpg", new Rectangle(dw2,
> dh2, dw2, dh2));
>
> //then generate the SVG file, this image is being generated successfully
>
>         boolean useCSS = true;
>         FileOutputStream fos = new FileOutputStream(new
> File("/tmp/mySVG.svg"));
>         Writer out = new OutputStreamWriter(fos, "UTF-8");
>         svg.stream(out, useCSS);
>
> //where tile() is
>     private void tile(org.w3c.dom.Document doc,
>                      String outputFilename,
>                      Rectangle aoi) throws Exception {
>         trans.addTranscodingHint(JPEGTranscoder.KEY_WIDTH,
>                                  new Float(aoi.width));
>         trans.addTranscodingHint(JPEGTranscoder.KEY_HEIGHT,
>                                  new Float(aoi.height));
>         trans.addTranscodingHint(JPEGTranscoder.KEY_AOI, aoi);
>
>         TranscoderInput input = new TranscoderInput(doc);
>         OutputStream ostream = new FileOutputStream(outputFilename);
>         TranscoderOutput output = new TranscoderOutput(ostream);
>         trans.transcode(input, output);
>
>         ostream.flush();
>         ostream.close();
>     }
>
> thanks in advance
>
> Kenji
> _______________________
> http://kenjiria.blogspot.com
> http://gaitabh.blogspot.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to