是否有任何库可以将SVG转换为JPG?除了蜡染?我使用了 BATIK,但我发现了一些像这个异常这样的问题:
java.lang.NullPointerException at org.apache.batik.css.engine.CSSEngine.getCascadedStyleMap(CSSEngine.java:684) at org.apache.batik.css.engine.CSSEngine.getComputedStyle(CSSEngine.java:755) at org. apache.batik.bridge.CSSUtilities.getComputedStyle(CSSUtilities.java:96) at org.apache.batik.bridge.CSSUtilities.convertDisplay(CSSUtilities.java:509) at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder. java:176) 在 org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:148) 在 org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:76) 在 org.apache.batik.transcoder .SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:165) 在 org.apache.batik.transcoder.image.ImageTranscoder.transcode(ImageTranscoder.java:86) 在 org.apache.batik.transcoder.XMLAbstractTranscoder。转码(XMLAbstractTranscoder.java:132)
这是我的代码:
JPEGTranscoder transcoder = new JPEGTranscoder();
transcoder.addTranscodingHint(JPEGTranscoder.KEY_XML_PARSER_CLASSNAME,
"org.apache.crimson.parser.XMLReaderImpl");
transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY,
new Float(1.0));
TranscoderInput input = new TranscoderInput(new FileInputStream("C:/Taha/SmartPlannerNew/rectangles.svg"));
OutputStream ostream = new FileOutputStream("C:/Taha/SmartPlannerNew/out.jpg");
TranscoderOutput output = new TranscoderOutput(ostream);
try {
transcoder.transcode(input, output);
} catch (TranscoderException e) {
System.out.println("error***************************************************************************************************************************");
e.printStackTrace();
}
System.out.println("done.");
ostream.close();
System.exit(0);
有人能帮帮我吗?