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

View File

@@ -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);
}
}
// 获取缩放后的新的宽和高