Rasterized image is (totally or partially) blank
Hi everybody, I'm using the transcoder functionality of batik 1.7 with more or less the same code as in the batik page examples: Transcoder transcoder = new JPEGTranscoder(); transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH, xResolution); transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_HEIGHT, yResolution); Rectangle2D rectangle = new Rectangle2D.Double(0, 0, width, height); transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_AOI, rectangle); transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, .8f); OutputStream ostream = null; try { TranscoderInput input = new TranscoderInput(doc); ostream = new FileOutputStream(output.jpg); TranscoderOutput output = new TranscoderOutput(ostream); transcoder.transcode(input, output); ostream.flush(); } catch (Exception e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(ostream); } Based on the input parameters (width, height, xResolution, yResolution) the output image is sometimes blank or partially blank (some parts are sort of truncated). I see no reasons why some parts are converted and some others are not, for the original SVG contains the same kind of elements in both converted and blank areas. I hope my problem is clear. Thanks for your help Paolo -- View this message in context: http://batik.2283329.n4.nabble.com/Rasterized-image-is-totally-or-partially-blank-tp4656120.html Sent from the Batik - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org
Re: Rasterized image is (totally or partially) blank
I found the solution, for those who might encounter the same issue. For some reason I can't understand, if the SVGDocument doesn't have width and height, SVGAbstractTranscoder.KEY_WIDTH and SVGAbstractTranscoder.KEY_HEIGHT are also used to determine the area to be rasterized and not only the pixel size of the output image. So, if the original image is 1000 by 1000 and I want to split it into 4 tiles 500x500, the left-down tile, which can be obtained through this code: transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH, 500); transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_HEIGHT, 500); Rectangle2D rectangle = new Rectangle2D.Double(500, 500, 1000, 1000); transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_AOI, rectangle); will be blank. To have it properly rasterized, I have to use SVGAbstractTranscoder.KEY_WIDTH and SVGAbstractTranscoder.KEY_HEIGHT at least equals to 1000, which will create a jpeg file 1000x1000. The solution is to add the width and height to the original image. -- View this message in context: http://batik.2283329.n4.nabble.com/Rasterized-image-is-totally-or-partially-blank-tp4656120p4656123.html Sent from the Batik - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org