SVGParser.java 文件源码

java
阅读 29 收藏 0 点赞 0 评论 0

项目:UltimateAndroid 作者:
private static SVG parse(InputStream in, Integer searchColor, Integer replaceColor, boolean whiteMode,
                             int targetWidth, int targetHeight) throws SVGParseException {
//        Util.debug("Parsing SVG...");
        try {
            long start = System.currentTimeMillis();
            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();
            final Picture picture = new Picture();
            SVGHandler handler = new SVGHandler(picture, targetWidth, targetHeight);
            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);
        }
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号