zoukankan      html  css  js  c++  java
  • svg转换工具

    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>
  • 相关阅读:
    DS博客作业05--查找
    DS博客作业04--图
    数据结构-栈,队列
    我の第六篇博客
    我の第五篇博客
    我の第四篇博客
    我の第三篇博客
    我の第二篇博客
    Java 购物车大作业01
    有理数类的设计
  • 原文地址:https://www.cnblogs.com/rubekid/p/4850563.html
Copyright © 2011-2022 走看看