工作中经常要把S60手机软件中的SVG矢量图转换成jpg图片格式,每次用图像编辑软件转换非常麻烦,于是自己用java写了一个支持拖放的小软件来减少一些重复的操作。Java只是在大二时候学过几个月,由于当时的128M内存电脑连个IDE都运行不起来,无奈之下放弃了,其实Java有很多现成的资源供我们利用,比如这个SVG转JPG,我们只要引用第三方库batik就可以直接操作,不用自己去研究算法一类的了,batik是一个基于Java的SVG项目,正好可以用上,结合[从MIF文件中提取SVG矢量图],就可以直接将MIF提取出SVG转换成Jpg
自己用Java做的一个辅助软件,功能太杂分了几个面板
下面是一个SVG转Jpg的例子
view sourceprint?01.import java.io.*;
02.
03.import org.apache.batik.transcoder.image.JPEGTranscoder;
04.import org.apache.batik.transcoder.TranscoderInput;
05.import org.apache.batik.transcoder.TranscoderOutput;
06.
07.public class SaveAsJPEG {
08.
09.
public static void main(String[] args) throws Exception {
10.
11.
// Create a JPEG transcoder
12.
JPEGTranscoder t = new JPEGTranscoder();
13.
14.
// Set the transcoding hints.
15.
t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY,
16.
new Float(.8));
17.
18.
// Create the transcoder input.
19.
String svgURI = new File(args[0]).toURL().toString();
20.
TranscoderInput input = new TranscoderInput(svgURI);
21.
22.
// Create the transcoder output.
23.
OutputStream ostream = new FileOutputStream("out.jpg");
24.
TranscoderOutput output = new TranscoderOutput(ostream);
25.
26.
// Save the image.
27.
t.transcode(input, output);
28.
29.
// Flush and close the stream.
30.
ostream.flush();
31.
ostream.close();
32.
System.exit(0);
33.
}
34.}
图片转换成svg格式步骤如下: 1、安装 inkscape sudo apt-get install inkscape 2、安装 python-lxml sudo apt-get install python-lxml 3、使用 inkscape 打开png图像 4、点中图像,选择命令 效果->图像->嵌入所有图像 5、保存成svg格式。
Photoshop|
Dreamweaver|
SVG|
WebGL|
Visual Studio|
PowerDesigner|
Eclipse|
Git|
Apache Ant|
Atom|
Composer|
CodeSmith|
Flex|
Gradle|
Maven|
Sublime Text3|
SVN|
Tableau|
Vim|
Chrome开发者工具|
OpenGL|
Unity|
Direct3D|
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....