batik-1.7beta1 seems to have fixed this issue ________________________________
From: Rich Quist Sent: Tuesday, August 21, 2007 11:49 AM To: [email protected] Subject: Transcoded images are being clipped.... I'm probably missing something really simple here. I'm using Batik 1.6 to generate svg output from a java application (using SVGGraphics2D) and then using a transcoder to convert that output to an image format. The problem I'm seeing is that the generated image is clipped/cut off on the right hand side. The original application dimensions are 600x400 (width x height) pixels, and the generated image is also that size, but nothing seems to draw beyond the 400-pixel mark on the right side. I'd appreciate any suggestions on how to resolve this. Here are the details: In a small test application's paint() method I'm drawing a filled rectangle, overlaying a few lines and outputting some text. I generate an svg file from this using the following code and, when viewed in a browser it looks fine: Dimension dim = panel.getSize(); // Get a DOMImplementation DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation(); // Create an instance of org.w3c.dom.Document Document document = domImpl.createDocument(null, "svg", null); // Create an instance of the SVG Generator SVGGraphics2D svgGenerator = new SVGGraphics2D(document); // Ask to render into the SVG Graphics2D implementation panel.print(svgGenerator); String svgFilePath = "c:\\temp\\batik.svg"; StringWriter svgOutput = new StringWriter(); svgGenerator.stream(svgOutput); FileOutputStream svgfout = new FileOutputStream(svgFilePath); svgfout.write(svgOutput.toString().getBytes()); svgfout.flush(); svgfout.close(); Then I create a StringReader from the svg output and attempt to transcode the output to an image format (jpeg/png): StringReader reader = new StringReader(svgOutput.toString()); JPEGTranscoder jpegt = new JPEGTranscoder(); jpegt.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(.8)); jpegt.addTranscodingHint(JPEGTranscoder.KEY_HEIGHT, new Float(dim.height)); jpegt.addTranscodingHint(JPEGTranscoder.KEY_WIDTH, new Float(dim.width)); FileOutputStream fout = new FileOutputStream("c:\\temp\\batik.jpg"); TranscoderOutput output = new TranscoderOutput(fout); TranscoderInput input = new TranscoderInput(reader); transcoder.transcode(input, output); fout.flush(); fout.close(); Thanks in advance.
