fix scale with bg

This commit is contained in:
Looly
2019-11-16 06:01:49 +08:00
parent fdcf383bfc
commit 814aa3d662
2 changed files with 9 additions and 8 deletions
+1
View File
@@ -13,6 +13,7 @@
### Bug修复
* 【core】 修复DateUtil.format使用DateTime时区失效问题(issue#I150I7@Gitee)
* 【core】 修复ZipUtil解压目录遗留问题(issue#I14NO3@Gitee)
* 【core】 修复等比缩放给定背景色无效问题(pr#625@Github)
-------------------------------------------------------------------------------------------------------------
@@ -279,14 +279,14 @@ public class Img implements Serializable {
double widthRatio = NumberUtil.div(width, srcWidth);
if (heightRatio == widthRatio) {
// 长宽都按照相同比例缩放时,返回缩放后的图片
return scale(width, height);
}
// 宽缩放比例多就按照宽缩放,否则按照高缩放
if (widthRatio < heightRatio) {
scale(width, (int) (srcHeight * widthRatio));
} else {
scale((int) (srcWidth * heightRatio), height);
scale(width, height);
} else{
// 宽缩放比例多就按照宽缩放,否则按照高缩放
if (widthRatio < heightRatio) {
scale(width, (int) (srcHeight * widthRatio));
} else {
scale((int) (srcWidth * heightRatio), height);
}
}
// 获取缩放后的新的宽和高