1 17 18 19 20 package org.apache.fop.render.rtf; 21 22 import org.apache.batik.transcoder.TranscoderException; 23 import org.apache.batik.transcoder.TranscoderInput; 24 import org.apache.batik.transcoder.TranscoderOutput; 25 import org.apache.batik.transcoder.image.JPEGTranscoder; 26 import org.apache.commons.io.output.ByteArrayOutputStream; 27 import org.apache.commons.logging.Log; 28 import org.apache.commons.logging.LogFactory; 29 import org.apache.fop.image.XMLImage; 30 31 34 public final class SVGConverter { 35 36 37 private static Log log = LogFactory.getLog(SVGConverter.class); 38 39 42 private SVGConverter() { 43 } 44 45 50 public static byte[] convertToJPEG(XMLImage image) { 51 JPEGTranscoder transcoder = new JPEGTranscoder(); 52 57 transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float (0.9f)); 58 TranscoderInput input = new TranscoderInput(image.getDocument()); 59 ByteArrayOutputStream baout = new ByteArrayOutputStream(16384); 60 TranscoderOutput output = new TranscoderOutput(baout); 61 try { 62 transcoder.transcode(input, output); 63 return baout.toByteArray(); 64 } catch (TranscoderException e) { 65 log.error(e); 66 return null; 67 } 68 } 69 70 } 71 | Popular Tags |