xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rich Quist" <Rich.Qu...@mathworks.com>
Subject RE: Transcoded images are being clipped....
Date Tue, 21 Aug 2007 18:42:13 GMT
batik-1.7beta1 seems to have fixed this issue 

From: Rich Quist 
Sent: Tuesday, August 21, 2007 11:49 AM
To: batik-users@xmlgraphics.apache.org
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 =
            // Create an instance of org.w3c.dom.Document
            Document document = domImpl.createDocument(null, "svg",
            // Create an instance of the SVG Generator
            SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
            // Ask to render into the SVG Graphics2D implementation
            String svgFilePath = "c:\\temp\\batik.svg";
            StringWriter svgOutput = new StringWriter();
            FileOutputStream svgfout = new

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();
                    new Float(.8));
     jpegt.addTranscodingHint(JPEGTranscoder.KEY_HEIGHT, new
     jpegt.addTranscodingHint(JPEGTranscoder.KEY_WIDTH, new

     FileOutputStream fout = new
     TranscoderOutput output = new TranscoderOutput(fout);
     TranscoderInput input = new TranscoderInput(reader);
      transcoder.transcode(input, output);
Thanks in advance.

View raw message