private static SVG parse(InputStream in, Integer searchColor, Integer replaceColor, boolean whiteMode) throws SVGParseException {
// Util.debug("Parsing SVG...");
try {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
final Picture picture = new Picture();
SVGHandler handler = new SVGHandler(picture);
handler.setColorSwap(searchColor, replaceColor);
handler.setWhiteMode(whiteMode);
xr.setContentHandler(handler);
xr.parse(new InputSource(in));
// Util.debug("Parsing complete in " + (System.currentTimeMillis() - start) + " millis.");
SVG result = new SVG(picture, handler.bounds);
// Skip bounds if it was an empty pic
if (!Float.isInfinite(handler.limits.top)) {
result.setLimits(handler.limits);
}
return result;
} catch (Exception e) {
throw new SVGParseException(e);
}
}
SVGParser.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:PdDroidPublisher
作者:
评论列表
文章目录