Hi,

On Tue, 2005-07-12 at 19:13 -0700, Gregory wrote:
> I just needed to set the created element namespace to
> the svg namespace.
> 
> What confuses me it's that squiggle renders the
> document properly while the  transcoder doesn't if I
> don't set the namespace.

If I am not wrong when batik parse the xml source, it build the svg
using appropriate namespace. In contrast when you build the DOM
manually, it is your responsibility to set correct namespace.

Maybe Thomas could provide better clarification on this matter.

Regards
Tonny Kohar
-- 
Sketsa 
SVG Graphics Editor
http://www.kiyut.com

> --- Gregory <[EMAIL PROTECTED]> wrote:
> 
> > Hi,
> > 
> > I created a very simple SVG DOM (see code above). 
> > 
> > If I serialize the DOM to a file and view the file
> > with squiggle its looks fine.
> > 
> > If I transcode the DOM to a png, tiff or jpeg file,
> > the result has the right dimensions but it's blank. 
> > 
> > Actually only a transparent layer with the
> > PNGTranscoder, a white layer with the JPGTranscoder
> > and a black layer with the TIFFTranscoder. But in
> > any
> > case I never get the actual drawing.
> > 
> > If I build the DOM from an URI instead of from
> > scratch, I get a correct result.
> >  
> > What did I missed?
> > 
> > --- java code ---
> > public static void main(String[] args) throws
> > Exception
> > {
> >   final DOMImplementation impl =
> > SVGDOMImplementation.getDOMImplementation();
> >   final String svgNS =
> > SVGDOMImplementation.SVG_NAMESPACE_URI;
> >   final Document doc = impl.createDocument(svgNS,
> > "svg", null);
> >   final Element root = doc.getDocumentElement();
> >   root.setAttribute("width", "504");
> >   root.setAttribute("height", "480");
> >   final Element rect = doc.createElement("rect");
> >   rect.setAttribute("x", "0");
> >   rect.setAttribute("y", "0");
> >   rect.setAttribute("width", "504");
> >   rect.setAttribute("height", "480");
> >   rect.setAttribute("fill", "yellow");
> >   root.appendChild(rect);
> >   
> >   // Save the dom to a file for verification
> >   final Transformer tr =
> > TransformerFactory.newInstance().newTransformer();
> >   tr.transform(new DOMSource(doc), new
> > StreamResult("/tmp/out/2.svg"));
> >   
> >   // The actual rasterization
> >   final Transcoder trc = new PNGTranscoder();
> >   final int screenDpi = 72;
> >   trc.addTranscodingHint(ImageTranscoder.KEY_WIDTH,
> > new Float(504));
> >  
> >
> trc.addTranscodingHint(ImageTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER,
> > new Float(25.4f / screenDpi));
> >   final TranscoderInput in = new
> > TranscoderInput(doc);
> >   final TranscoderOutput out = new
> > TranscoderOutput(new BufferedOutputStream(new
> > FileOutputStream("/tmp/out/out.png")));
> >   trc.transcode(in, out);
> >   out.getOutputStream().flush();
> >   out.getOutputStream().close();
> >   System.out.println("done");
> > }
> > 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to