mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-04 04:37:59 +08:00
fix code
This commit is contained in:
parent
8c7106d7f3
commit
1756535595
@ -10,6 +10,7 @@
|
|||||||
* 【core 】 新增DatePattern.createFormatter(pr#483@Gitee)
|
* 【core 】 新增DatePattern.createFormatter(pr#483@Gitee)
|
||||||
* 【core 】 增加IdUtil.getSnowflakeNextId(pr#485@Gitee)
|
* 【core 】 增加IdUtil.getSnowflakeNextId(pr#485@Gitee)
|
||||||
* 【log 】 log4j2的编译依赖改为api,core为test依赖(pr#2019@Github)
|
* 【log 】 log4j2的编译依赖改为api,core为test依赖(pr#2019@Github)
|
||||||
|
* 【core 】 Img.scale缩小默认使用平滑模式(issue#I4MY6X@Gitee)
|
||||||
*
|
*
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【core 】 LineReadWatcher#onModify文件清空判断问题(issue#2013@Github)
|
* 【core 】 LineReadWatcher#onModify文件清空判断问题(issue#2013@Github)
|
||||||
|
@ -253,23 +253,30 @@ public class Img implements Serializable {
|
|||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public Img scale(int width, int height) {
|
public Img scale(int width, int height) {
|
||||||
|
return scale(width, height, Image.SCALE_SMOOTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缩放图像(按长宽缩放)<br>
|
||||||
|
* 注意:目标长宽与原图不成比例会变形
|
||||||
|
*
|
||||||
|
* @param width 目标宽度
|
||||||
|
* @param height 目标高度
|
||||||
|
* @param scaleType 缩放类型,可选{@link Image#SCALE_SMOOTH}平滑模式或{@link Image#SCALE_DEFAULT}默认模式
|
||||||
|
* @return this
|
||||||
|
* @since 5.7.18
|
||||||
|
*/
|
||||||
|
public Img scale(int width, int height, int scaleType) {
|
||||||
final Image srcImg = getValidSrcImg();
|
final Image srcImg = getValidSrcImg();
|
||||||
|
|
||||||
int srcHeight = srcImg.getHeight(null);
|
int srcHeight = srcImg.getHeight(null);
|
||||||
int srcWidth = srcImg.getWidth(null);
|
int srcWidth = srcImg.getWidth(null);
|
||||||
int scaleType;
|
|
||||||
if (srcHeight == height && srcWidth == width) {
|
if (srcHeight == height && srcWidth == width) {
|
||||||
// 源与目标长宽一致返回原图
|
// 源与目标长宽一致返回原图
|
||||||
this.targetImage = srcImg;
|
this.targetImage = srcImg;
|
||||||
return this;
|
return this;
|
||||||
} else if (srcHeight < height || srcWidth < width) {
|
|
||||||
// 放大图片使用平滑模式
|
|
||||||
scaleType = Image.SCALE_SMOOTH;
|
|
||||||
} else {
|
|
||||||
scaleType = Image.SCALE_DEFAULT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (ImgUtil.IMAGE_TYPE_PNG.equals(this.targetImageType)) {
|
if (ImgUtil.IMAGE_TYPE_PNG.equals(this.targetImageType)) {
|
||||||
// png特殊处理,借助AffineTransform可以实现透明度保留
|
// png特殊处理,借助AffineTransform可以实现透明度保留
|
||||||
final double sx = NumberUtil.div(width, srcWidth);// 宽度缩放比
|
final double sx = NumberUtil.div(width, srcWidth);// 宽度缩放比
|
||||||
|
@ -207,7 +207,7 @@ public class StyleUtil {
|
|||||||
* 创建数据格式并获取格式
|
* 创建数据格式并获取格式
|
||||||
*
|
*
|
||||||
* @param workbook {@link Workbook}
|
* @param workbook {@link Workbook}
|
||||||
* @param format 数据格式
|
* @param format 数据格式
|
||||||
* @return 数据格式
|
* @return 数据格式
|
||||||
* @since 5.5.5
|
* @since 5.5.5
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user