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");
}



                
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
 

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

Reply via email to