首页 > 其他 > 详细

svg转换工具

时间:2015-10-01 00:35:05      阅读:314      评论:0      收藏:0      [点我收藏+]
package com.rubekid.springmvc.utils;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.image.PNGTranscoder;

/**
 * svg工具
 * @author rubekid
 *
 */
public class SvgUtils {
    
    
    public static byte[] toPng(byte[] svgByteArray) throws TranscoderException, IOException{
        return toPng(new ByteArrayInputStream(svgByteArray));
    }
    
    public static byte[] toPng(InputStream inputStream) throws TranscoderException, IOException{
        PNGTranscoder transcoder = new PNGTranscoder();
        TranscoderInput input = new TranscoderInput(inputStream);
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        TranscoderOutput output = new TranscoderOutput(outputStream);
        transcoder.transcode(input, output);
        outputStream.close();
        return outputStream.toByteArray();
    }
}

 

 

       <dependency>
        <groupId>batik</groupId>
        <artifactId>batik-transcoder</artifactId>
        <version>1.6-1</version>
    </dependency>

 

svg转换工具

原文:http://www.cnblogs.com/rubekid/p/4850563.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!