xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Gash <gasha...@gashalot.com>
Subject [Batik 1.5b5] PNGTranscoder creating blank images
Date Tue, 03 Jun 2003 15:50:13 GMT
I am using the SVG generator to create a new SVG by drawing on a
Graphics2D object.  Once updates are complete, I need to rasterize
this image to a PNG.  When I do so, the PNGTranscoder (and
JPEGTranscoder) continuously produce appropriately sized, but blank
images (IE- a big image full of background color).

I have saved the SVG that I am attemting to rasterize, and Adobe's SVG
viewer displays is properly.  What might I be missing that could cause
problems like this?

Here is the code:

DOMImplementation domImpl = SVGDOMImplementation.getDOMImplementation();
Document doc =
domImpl.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg", null);

SVGGraphics2D svgGenerator = new SVGGraphics2D(doc);
Element svgRoot = doc.getDocumentElement();
cr.drawScope(svgGenerator, 400, 400);
svgGenerator.getRoot(svgRoot);
svgRoot.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI, "width", "400");
svgRoot.setAttributeNS(SVGDOMImplementation.SVG_NAMESPACE_URI, "height", "400");

// prepare the input and output for the transcoding process
TranscoderInput ti = new TranscoderInput(doc);
OutputStream outFile = new
FileOutputStream("test/radar.png");
TranscoderOutput to = new TranscoderOutput(outFile);

// prep the PNG transcoder for output
Transcoder t = new PNGTranscoder();
t.addTranscodingHint(org.apache.batik.transcoder.image.ImageTranscoder.KEY_BACKGROUND_COLOR,
Color.WHITE);
t.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH, new Float(400));
t.addTranscodingHint(SVGAbstractTranscoder.KEY_HEIGHT, new Float(400));

Writer out = new FileWriter("test/radar.xml");
XMLSerializer xs = new XMLSerializer(out, new OutputFormat(doc));
xs.serialize(doc);
           
// transcode
t.transcode(ti, to);

outFile.flush();
outFile.close();

-- 
Robert Gash, gashalot@gashalot.com
(Web) http://gashalot.com/
(PGP) http://gashalot.com/pgpkeys.txt


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message