图片压缩不失真
来源:互联网 发布:2017淘宝扣分清零规则 编辑:程序博客网 时间:2024/04/28 19:45
public static void reduceImg(String imgsrc, String imgdist, int widthdist,
int heightdist) {
try {
File srcfile = new File(imgsrc);
if (!srcfile.exists()) {
return;
}
Image src = javax.imageio.ImageIO.read(srcfile);
BufferedImage tag= new BufferedImage((int) widthdist, (int) heightdist,
BufferedImage.TYPE_INT_RGB);
tag.getGraphics().drawImage(src.getScaledInstance(widthdist, heightdist, Image.SCALE_SMOOTH), 0, 0, null);
/// tag.getGraphics().drawImage(src.getScaledInstance(widthdist, heightdist, Image.SCALE_AREA_AVERAGING), 0, 0, null);
FileOutputStream out = new FileOutputStream(imgdist);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(tag);
out.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
int heightdist) {
try {
File srcfile = new File(imgsrc);
if (!srcfile.exists()) {
return;
}
Image src = javax.imageio.ImageIO.read(srcfile);
BufferedImage tag= new BufferedImage((int) widthdist, (int) heightdist,
BufferedImage.TYPE_INT_RGB);
tag.getGraphics().drawImage(src.getScaledInstance(widthdist, heightdist, Image.SCALE_SMOOTH), 0, 0, null);
/// tag.getGraphics().drawImage(src.getScaledInstance(widthdist, heightdist, Image.SCALE_AREA_AVERAGING), 0, 0, null);
FileOutputStream out = new FileOutputStream(imgdist);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(tag);
out.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
0 0
- 图片压缩不失真
- 图片极致压缩,不失真
- android图片压缩不失真
- 图片压缩算法,保证图片不失真
- VB压缩图片(不失真)
- 笔记:Android不失真压缩图片
- Android实现图片压缩并且不失真
- android图片压缩不失真实战
- PS压缩图片文件大小,不失真!!!
- StretchBlt()压缩图片失真
- PS如何不失真压缩图片【网站上应用】
- Android高效压缩图片不失真的方法总结
- iOS 根据屏幕宽高等比压缩图片 不失真
- Get技能---如何压缩图片文件大小不失真
- 不失真缩放图片
- PS图片压缩教程,教你快速压缩jpg图片文件的大小而又不失真!
- 解决StretchBlt()压缩图片失真
- 解决StretchBlt()压缩图片失真
- linux spec文档解析
- 调试的错误就是编程给你最好的东西,因为在每个错误上面都标志着前进的一步
- 极光推送技术原理:移动无线网络长连接
- 我的测试
- 密码SwitchView
- 图片压缩不失真
- mac下安装破解版adobe photoshop cs6
- [Step By Step]使用SLT工具从SAP导入数据到SAP HANA
- java并发编程学习笔记-原理篇
- storm简述最为清楚的文章
- org.apache.jasper.JasperException
- JAVA实现排队论
- 自己封装的轮播工具
- android随笔03——手势解析器