以png格式保存svg图片
2018-03-09 15:58
246 查看
转载请注明:https://blog.csdn.net/qfashly/article/details/79498701
最近由于业务需要,需要将前端查询的数据在浏览器上以图片的形式展示,然后回传到后台以文件形式存储在硬盘上。
最近由于业务需要,需要将前端查询的数据在浏览器上以图片的形式展示,然后回传到后台以文件形式存储在硬盘上。
/** * @Title: convertToPng * @Description: * @param svgCode 前端传回的svg字符串 * @param pngFilePath 输出文件名,如:D:\Myworkspace\svg.png * @throws IOException * @throws TranscoderException * @date 2018-3-9 下午3:51:32 */ public static void convertToPng(String svgCode, String pngFilePath) throws IOException, TranscoderException { File file = new File(pngFilePath); FileOutputStream outputStream = null; try { file.createNewFile(); outputStream = new FileOutputStream(file); byte[] bytes = svgCode.getBytes("UTF-8"); PNGTranscoder t = new PNGTranscoder(); TranscoderInput input = new TranscoderInput(new ByteArrayInputStream(bytes)); TranscoderOutput output = new TranscoderOutput(outputStream); t.transcode(input, output); outputStream.flush(); } finally { if (outputStream != null) { try { outputStream.close(); } catch (IOException e) { logger.error("",e); } } } }
相关文章推荐
- Android把svg图片转为jpg保存到相册图库
- android 网络加载图片并保存本地,压缩,jpeg png格式分析
- 动态生成的图片保存成png格式
- 模拟地图撒点,将随机产生的一些点以圆的形式画在画布上并保存为png格式的图片
- js实现canvas保存图片为png格式并下载到本地的方法
- js svg保存为图片
- qt 保存为svg图片
- java将svg图片转换为png格式图片
- PS教程新手入门(二)--保存清晰透明的.Png格式图片的方法和技巧教程
- 保存为BMP,Jpg,Png格式的图片
- Android把svg图片转为jpg保存到相册图库
- java将svg图片转换为png格式图片
- JavaScript 下载svg图片为png格式
- PCL1.8创建深度图并保存成png格式图片代码(生成深度图的原理一般就是透视投影或者正交投影)
- 爬虫记录(2)——简单爬取一个页面的图片并保存
- 选着图片后可以编辑图片和如何使用摄像机获取图片并保存相册
- 多幅图片并保存
- Android ScrollView截图和图片保存到相册的方式
- 在ASP.net中保存/取出图片入/从SQL数据库(可用于上传图片)
- iOS 将图片保存到本地相册