diff --git a/hutool-swing/src/main/java/org/dromara/hutool/swing/img/DisplayText.java b/hutool-swing/src/main/java/org/dromara/hutool/swing/img/DisplayText.java new file mode 100644 index 000000000..e33f61605 --- /dev/null +++ b/hutool-swing/src/main/java/org/dromara/hutool/swing/img/DisplayText.java @@ -0,0 +1,176 @@ +package org.dromara.hutool.swing.img; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Point; +import java.io.Serializable; +import java.util.Objects; + +/** + * 显示文本,用于保存在图片上绘图的文本信息,包括内容、字体、大小、位置和透明度等 + * + * @author looly + * @since 6.0.0 + */ +public class DisplayText implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 构建DisplayText + * + * @param text 文本 + * @param color 文本颜色 + * @param font 文本显示字体 + * @param point 起始左边位置 + * @param alpha 透明度 + * @return DisplayText + */ + public static DisplayText of(final String text, final Color color, final Font font, final Point point, final float alpha) { + return new DisplayText(text, color, font, point, alpha); + } + + private String pressText; + private Color color; + private Font font; + private Point point; + private float alpha; + + /** + * 构造 + * + * @param text 文本 + * @param color 文本颜色 + * @param font 文本显示字体 + * @param point 起始左边位置 + * @param alpha 透明度 + */ + public DisplayText(final String text, final Color color, final Font font, final Point point, final float alpha) { + this.pressText = text; + this.color = color; + this.font = font; + this.point = point; + this.alpha = alpha; + } + + /** + * 获取文本 + * + * @return 获取文本 + */ + public String getPressText() { + return pressText; + } + + /** + * 设置文本 + * + * @param pressText 文本 + */ + public void setPressText(final String pressText) { + this.pressText = pressText; + } + + /** + * 获取文本颜色 + * + * @return 文本颜色 + */ + public Color getColor() { + return color; + } + + /** + * 设置文本颜色 + * + * @param color 文本颜色 + */ + public void setColor(final Color color) { + this.color = color; + } + + /** + * 获取字体 + * + * @return 字体 + */ + public Font getFont() { + return font; + } + + /** + * 设置字体 + * + * @param font 字体 + */ + public void setFont(final Font font) { + this.font = font; + } + + /** + * 获取二维坐标点 + * + * @return 二维坐标点 + */ + public Point getPoint() { + return point; + } + + /** + * 设置二维坐标点 + * + * @param point 二维坐标点 + */ + public void setPoint(final Point point) { + this.point = point; + } + + /** + * 获取透明度 + * + * @return 透明度 + */ + public float getAlpha() { + return alpha; + } + + /** + * 设置透明度 + * + * @param alpha 透明度 + */ + public void setAlpha(final float alpha) { + this.alpha = alpha; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final DisplayText that = (DisplayText) o; + return Float.compare(alpha, that.alpha) == 0 + && Objects.equals(pressText, that.pressText) + && Objects.equals(color, that.color) + && Objects.equals(font, that.font) + && Objects.equals(point, that.point); + } + + @Override + public int hashCode() { + return Objects.hash(pressText, color, font, point, alpha); + } + + @Override + public String toString() { + return "DisplayText{" + + "pressText='" + pressText + '\'' + + ", color=" + color + + ", font=" + font + + ", point=" + point + + ", alpha=" + alpha + + '}'; + } +} diff --git a/hutool-swing/src/main/java/org/dromara/hutool/swing/img/Img.java b/hutool-swing/src/main/java/org/dromara/hutool/swing/img/Img.java index 44eb63518..5b488b2d6 100644 --- a/hutool-swing/src/main/java/org/dromara/hutool/swing/img/Img.java +++ b/hutool-swing/src/main/java/org/dromara/hutool/swing/img/Img.java @@ -477,23 +477,20 @@ public class Img implements Serializable { * @return 处理后的图像 */ public Img pressText(final String pressText, final Color color, final Font font, final int x, final int y, final float alpha) { - return pressText(pressText, color, font, new Point(x, y), alpha); + return pressText(DisplayText.of(pressText, color, font, new Point(x, y), alpha)); } /** * 给图片添加文字水印
* 此方法只在给定位置写出一个水印字符串 * - * @param pressText 水印文字 - * @param color 水印的字体颜色 - * @param font {@link Font} 字体相关信息 - * @param point 绘制字符串的位置坐标 - * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + * @param displayText 显示的文本信息 * @return 处理后的图像 */ - public Img pressText(final String pressText, final Color color, Font font, final Point point, final float alpha) { + public Img pressText(final DisplayText displayText) { final BufferedImage targetImage = ImgUtil.toBufferedImage(getValidSrcImg(), this.targetImageType); + Font font = displayText.getFont(); if (null == font) { // 默认字体 font = FontUtil.createSansSerifFont((int) (targetImage.getHeight() * 0.75)); @@ -501,16 +498,17 @@ public class Img implements Serializable { final Graphics2D g = targetImage.createGraphics(); // 透明度 - g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha)); + g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, displayText.getAlpha())); + final Point point = displayText.getPoint(); // 绘制 if (positionBaseCentre) { // 基于中心绘制 - GraphicsUtil.drawString(g, pressText, font, color, + GraphicsUtil.drawString(g, displayText.getPressText(), font, displayText.getColor(), new Rectangle(point.x, point.y, targetImage.getWidth(), targetImage.getHeight())); } else { // 基于左上角绘制 - GraphicsUtil.drawString(g, pressText, font, color, point); + GraphicsUtil.drawString(g, displayText.getPressText(), font, displayText.getColor(), point); } // 收笔 @@ -630,11 +628,11 @@ public class Img implements Serializable { g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha)); //获取水印图片本身的长宽 - int pressImageWidth = pressImage.getWidth(null); - int pressImageHeight = pressImage.getHeight(null); - Dimension dimension = new Dimension(pressImageWidth, pressImageHeight); + final int pressImageWidth = pressImage.getWidth(null); + final int pressImageHeight = pressImage.getHeight(null); + final Dimension dimension = new Dimension(pressImageWidth, pressImageHeight); final int intervalHeight = dimension.height * lineHeight; - // 在画笔按照画布中心旋转后,达到45度时,上下左右会出现空白区,此处各延申长款的1.5倍实现全覆盖 + // 在画笔按照画布中心旋转后,达到45度时,上下左右会出现空白区,此处各延伸长款的1.5倍实现全覆盖 int y = -targetHeight >> 1 ; while (y < targetHeight * 1.5) { int x = -targetWidth >> 1; diff --git a/hutool-swing/src/main/java/org/dromara/hutool/swing/img/ImgUtil.java b/hutool-swing/src/main/java/org/dromara/hutool/swing/img/ImgUtil.java index a9dede574..b51b5459a 100644 --- a/hutool-swing/src/main/java/org/dromara/hutool/swing/img/ImgUtil.java +++ b/hutool-swing/src/main/java/org/dromara/hutool/swing/img/ImgUtil.java @@ -445,7 +445,7 @@ public class ImgUtil { * 图像切割(指定切片的行数和列数) * * @param srcImageFile 源图像文件 - * @param targetDir 切片目标文件夹 + * @param targetDir 切片目标文件夹 * @param formatName 格式名称,即图片格式后缀 * @param rows 目标切片行数。默认2,必须是范围 [1, 20] 之内 * @param cols 目标切片列数。默认2,必须是范围 [1, 20] 之内 @@ -489,7 +489,7 @@ public class ImgUtil { for (int j = 0; j < cols; j++) { tag = cut(srcImage, new Rectangle(j * targetWidth, i * targetHeight, targetWidth, targetHeight)); // 输出为文件 - write(tag, new File(destDir, "_r" + i + "_c" + j + "." + formatName)); + write(tag, new File(destDir, "_r" + i + "_c" + j + "." + formatName)); } } } @@ -500,7 +500,7 @@ public class ImgUtil { /** * 图像类型转换:GIF=》JPG、GIF=》PNG、PNG=》JPG、PNG=》GIF(X)、BMP=》PNG * - * @param srcImageFile 源图像文件 + * @param srcImageFile 源图像文件 * @param targetImageFile 目标图像文件 */ public static void convert(final File srcImageFile, final File targetImageFile) { @@ -523,8 +523,8 @@ public class ImgUtil { * 图像类型转换:GIF=》JPG、GIF=》PNG、PNG=》JPG、PNG=》GIF(X)、BMP=》PNG
* 此方法并不关闭流 * - * @param srcStream 源图像流 - * @param formatName 包含格式非正式名称的 String:如JPG、JPEG、GIF等 + * @param srcStream 源图像流 + * @param formatName 包含格式非正式名称的 String:如JPG、JPEG、GIF等 * @param targetStream 目标图像输出流 * @since 3.0.9 */ @@ -536,8 +536,8 @@ public class ImgUtil { * 图像类型转换:GIF=》JPG、GIF=》PNG、PNG=》JPG、PNG=》GIF(X)、BMP=》PNG
* 此方法并不关闭流 * - * @param srcImage 源图像流 - * @param formatName 包含格式非正式名称的 String:如JPG、JPEG、GIF等 + * @param srcImage 源图像流 + * @param formatName 包含格式非正式名称的 String:如JPG、JPEG、GIF等 * @param targetImageStream 目标图像输出流 * @since 4.1.14 */ @@ -726,14 +726,9 @@ public class ImgUtil { * @param imageFile 源图像文件 * @param destFile 目标图像文件 * @param pressText 水印文字 - * @param color 水印的字体颜色 - * @param font {@link Font} 字体相关信息,如果默认则为{@code null} - * @param x 修正值。 默认在中间,偏移量相对于中间偏移 - * @param y 修正值。 默认在中间,偏移量相对于中间偏移 - * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 */ - public static void pressText(final File imageFile, final File destFile, final String pressText, final Color color, final Font font, final int x, final int y, final float alpha) { - pressText(read(imageFile), destFile, pressText, color, font, x, y, alpha); + public static void pressText(final File imageFile, final File destFile, final DisplayText pressText) { + pressText(read(imageFile), destFile, pressText); } /** @@ -742,32 +737,10 @@ public class ImgUtil { * * @param srcStream 源图像流 * @param destStream 目标图像流 - * @param pressText 水印文字 - * @param color 水印的字体颜色 - * @param font {@link Font} 字体相关信息,如果默认则为{@code null} - * @param x 修正值。 默认在中间,偏移量相对于中间偏移 - * @param y 修正值。 默认在中间,偏移量相对于中间偏移 - * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + * @param pressText 水印文本信息 */ - public static void pressText(final InputStream srcStream, final OutputStream destStream, final String pressText, final Color color, final Font font, final int x, final int y, final float alpha) { - pressText(read(srcStream), getImageOutputStream(destStream), pressText, color, font, x, y, alpha); - } - - /** - * 给图片添加文字水印
- * 此方法并不关闭流 - * - * @param srcStream 源图像流 - * @param destStream 目标图像流 - * @param pressText 水印文字 - * @param color 水印的字体颜色 - * @param font {@link Font} 字体相关信息,如果默认则为{@code null} - * @param x 修正值。 默认在中间,偏移量相对于中间偏移 - * @param y 修正值。 默认在中间,偏移量相对于中间偏移 - * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 - */ - public static void pressText(final ImageInputStream srcStream, final ImageOutputStream destStream, final String pressText, final Color color, final Font font, final int x, final int y, final float alpha) { - pressText(read(srcStream), destStream, pressText, color, font, x, y, alpha); + public static void pressText(final InputStream srcStream, final OutputStream destStream, final DisplayText pressText) { + pressText(read(srcStream), getImageOutputStream(destStream), pressText); } /** @@ -776,17 +749,12 @@ public class ImgUtil { * * @param srcImage 源图像 * @param destFile 目标流 - * @param pressText 水印文字 - * @param color 水印的字体颜色 - * @param font {@link Font} 字体相关信息,如果默认则为{@code null} - * @param x 修正值。 默认在中间,偏移量相对于中间偏移 - * @param y 修正值。 默认在中间,偏移量相对于中间偏移 - * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + * @param pressText 水印文字信息 * @throws IORuntimeException IO异常 * @since 3.2.2 */ - public static void pressText(final Image srcImage, final File destFile, final String pressText, final Color color, final Font font, final int x, final int y, final float alpha) throws IORuntimeException { - write(pressText(srcImage, pressText, color, font, x, y, alpha), destFile); + public static void pressText(final Image srcImage, final File destFile, final DisplayText pressText) throws IORuntimeException { + write(pressText(srcImage, pressText), destFile); } /** @@ -795,17 +763,12 @@ public class ImgUtil { * * @param srcImage 源图像 * @param to 目标流 - * @param pressText 水印文字 - * @param color 水印的字体颜色 - * @param font {@link Font} 字体相关信息,如果默认则为{@code null} - * @param x 修正值。 默认在中间,偏移量相对于中间偏移 - * @param y 修正值。 默认在中间,偏移量相对于中间偏移 - * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + * @param pressText 水印文字信息 * @throws IORuntimeException IO异常 * @since 3.2.2 */ - public static void pressText(final Image srcImage, final OutputStream to, final String pressText, final Color color, final Font font, final int x, final int y, final float alpha) throws IORuntimeException { - pressText(srcImage, getImageOutputStream(to), pressText, color, font, x, y, alpha); + public static void pressText(final Image srcImage, final OutputStream to, final DisplayText pressText) throws IORuntimeException { + pressText(srcImage, getImageOutputStream(to), pressText); } /** @@ -814,16 +777,11 @@ public class ImgUtil { * * @param srcImage 源图像 * @param destImageStream 目标图像流 - * @param pressText 水印文字 - * @param color 水印的字体颜色 - * @param font {@link Font} 字体相关信息,如果默认则为{@code null} - * @param x 修正值。 默认在中间,偏移量相对于中间偏移 - * @param y 修正值。 默认在中间,偏移量相对于中间偏移 - * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + * @param pressText 水印文字信息 * @throws IORuntimeException IO异常 */ - public static void pressText(final Image srcImage, final ImageOutputStream destImageStream, final String pressText, final Color color, final Font font, final int x, final int y, final float alpha) throws IORuntimeException { - writeJpg(pressText(srcImage, pressText, color, font, x, y, alpha), destImageStream); + public static void pressText(final Image srcImage, final ImageOutputStream destImageStream, final DisplayText pressText) throws IORuntimeException { + writeJpg(pressText(srcImage, pressText), destImageStream); } /** @@ -831,76 +789,18 @@ public class ImgUtil { * 此方法并不关闭流 * * @param srcImage 源图像 - * @param pressText 水印文字 - * @param color 水印的字体颜色 - * @param font {@link Font} 字体相关信息,如果默认则为{@code null} - * @param x 修正值。 默认在中间,偏移量相对于中间偏移 - * @param y 修正值。 默认在中间,偏移量相对于中间偏移 - * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 + * @param pressText 水印文字信息 * @return 处理后的图像 * @since 3.2.2 */ - public static Image pressText(final Image srcImage, final String pressText, final Color color, final Font font, final int x, final int y, final float alpha) { - return Img.from(srcImage).pressText(pressText, color, font, x, y, alpha).getImg(); - } - - - /** - * 给图片添加全屏文字水印
- * - * @param imageFile 源图像文件 - * @param destFile 目标图像文件 - * @param pressText 水印文字 - * @param color 水印的字体颜色 - * @param font {@link Font} 字体相关信息,如果默认则为{@code null} - * @param lineHeight 行高 - * @param degree 水印文字旋转角度 - * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 - * @throws IORuntimeException IO异常 - */ - public static void pressTextFull(final File imageFile, final File destFile, final String pressText, final Color color, final Font font, final int lineHeight, final int degree, final float alpha) throws IORuntimeException { - pressTextFull(read(imageFile), destFile, pressText, color, font, lineHeight, degree, alpha); + public static Image pressText(final Image srcImage, final DisplayText pressText) { + return Img.from(srcImage).pressText(pressText).getImg(); } /** * 给图片添加全屏文字水印
* 此方法并不关闭流 * - * @param srcStream 源图像流 - * @param destStream 目标图像流 - * @param pressText 水印文字 - * @param color 水印的字体颜色 - * @param font {@link Font} 字体相关信息,如果默认则为{@code null} - * @param lineHeight 行高 - * @param degree 水印文字旋转角度 - * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 - * @throws IORuntimeException IO异常 - */ - public static void pressTextFull(final InputStream srcStream, final OutputStream destStream, final String pressText, final Color color, final Font font, final int lineHeight, final int degree, final float alpha) throws IORuntimeException { - writeJpg(pressTextFull(read(srcStream), pressText, color, font, lineHeight, degree, alpha), destStream); - } - - - /** - * 给图片添加全屏文字水印
- * 此方法并不关闭流 - * @param srcImage 源图像 - * @param destFile 目标图像文件 - * @param pressText 水印文字 - * @param color 水印的字体颜色 - * @param font {@link Font} 字体相关信息,如果默认则为{@code null} - * @param lineHeight 行高 - * @param degree 水印文字旋转角度 - * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 - * @throws IORuntimeException IO异常 - */ - public static void pressTextFull(final Image srcImage, final File destFile, final String pressText, final Color color, final Font font, final int lineHeight, final int degree, final float alpha) throws IORuntimeException { - write(pressTextFull(srcImage, pressText, color, font, lineHeight, degree, alpha), destFile); - } - - /** - * 给图片添加全屏文字水印
- * 此方法并不关闭流 * @param srcImage 源图像 * @param pressText 水印文字 * @param color 水印的字体颜色 @@ -944,22 +844,6 @@ public class ImgUtil { pressImage(read(srcStream), getImageOutputStream(destStream), pressImg, x, y, alpha); } - /** - * 给图片添加图片水印
- * 此方法并不关闭流 - * - * @param srcStream 源图像流 - * @param destStream 目标图像流 - * @param pressImg 水印图片,可以使用{@link ImageIO#read(File)}方法读取文件 - * @param x 修正值。 默认在中间,偏移量相对于中间偏移 - * @param y 修正值。 默认在中间,偏移量相对于中间偏移 - * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 - * @throws IORuntimeException IO异常 - */ - public static void pressImage(final ImageInputStream srcStream, final ImageOutputStream destStream, final Image pressImg, final int x, final int y, final float alpha) throws IORuntimeException { - pressImage(read(srcStream), destStream, pressImg, x, y, alpha); - } - /** * 给图片添加图片水印
* 此方法并不关闭流 @@ -1040,7 +924,6 @@ public class ImgUtil { return Img.from(srcImage).pressImage(pressImg, rectangle, alpha).getImg(); } - /** * 给图片添加全屏图片水印
* @@ -1052,7 +935,8 @@ public class ImgUtil { * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 * @throws IORuntimeException IO异常 */ - public static void pressImageFull(final File imageFile, final File destFile, final File pressImageFile, final int lineHeight, final int degree, final float alpha) throws IORuntimeException { + public static void pressImageFull(final File imageFile, final File destFile, final File pressImageFile, + final int lineHeight, final int degree, final float alpha) throws IORuntimeException { write(pressImageFull(read(imageFile), read(pressImageFile), lineHeight, degree, alpha), destFile); } @@ -1068,15 +952,15 @@ public class ImgUtil { * @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字 * @throws IORuntimeException IO异常 */ - public static void pressImageFull(final InputStream srcStream, final OutputStream destStream, final InputStream pressStream, final int lineHeight, final int degree, final float alpha) throws IORuntimeException { + public static void pressImageFull(final InputStream srcStream, final OutputStream destStream, + final InputStream pressStream, final int lineHeight, final int degree, final float alpha) throws IORuntimeException { writeJpg(pressImageFull(read(srcStream), read(pressStream), lineHeight, degree, alpha), destStream); } - - /** * 给图片添加全屏图像水印
* 此方法并不关闭流 + * * @param srcImage 源图像 * @param pressImage 水印图像 * @param lineHeight 行高 @@ -1087,8 +971,6 @@ public class ImgUtil { public static Image pressImageFull(final Image srcImage, final Image pressImage, final int lineHeight, final int degree, final float alpha) { return Img.from(srcImage).pressImageFull(pressImage, lineHeight, degree, alpha).getImg(); } - - // endregion // region ----- rotate @@ -1248,7 +1130,7 @@ public class ImgUtil { * {@link Image} 转 {@link RenderedImage}
* 首先尝试强转,否则新建一个{@link BufferedImage}后重新绘制,使用 {@link BufferedImage#TYPE_INT_RGB} 模式。 * - * @param img {@link Image} + * @param img {@link Image} * @param imageType 目标图片类型,例如jpg或png等 * @return {@link BufferedImage} * @since 4.3.2 @@ -1265,7 +1147,7 @@ public class ImgUtil { * {@link Image} 转 {@link BufferedImage}
* 首先尝试强转,否则新建一个{@link BufferedImage}后重新绘制,使用 imageType 模式 * - * @param img {@link Image} + * @param img {@link Image} * @param imageType 目标图片类型,例如jpg或png等 * @return {@link BufferedImage} */ @@ -1681,7 +1563,7 @@ public class ImgUtil { * * @param image {@link Image} * @param imageType 图片类型(图片扩展名),{@code null}表示使用RGB模式(JPG) - * @param out 写出到的目标流 + * @param out 写出到的目标流 * @param quality 质量,数字为0~1(不包括0和1)表示质量压缩比,除此数字外设置表示不压缩 * @param backgroundColor 背景色{@link Color} * @throws IORuntimeException IO异常 @@ -1696,10 +1578,10 @@ public class ImgUtil { /** * 通过{@link ImageWriter}写出图片到输出流 * - * @param image 图片 + * @param image 图片 * @param imageType 图片类型 - * @param output 输出的Image流{@link ImageOutputStream} - * @param quality 质量,数字为0~1(不包括0和1)表示质量压缩比,除此数字外设置表示不压缩 + * @param output 输出的Image流{@link ImageOutputStream} + * @param quality 质量,数字为0~1(不包括0和1)表示质量压缩比,除此数字外设置表示不压缩 * @since 4.3.2 */ public static void write(final Image image, final String imageType, final ImageOutputStream output, final float quality) { diff --git a/hutool-swing/src/test/java/org/dromara/hutool/swing/img/ImgUtilTest.java b/hutool-swing/src/test/java/org/dromara/hutool/swing/img/ImgUtilTest.java index 21a24f0f0..0d9004c0f 100644 --- a/hutool-swing/src/test/java/org/dromara/hutool/swing/img/ImgUtilTest.java +++ b/hutool-swing/src/test/java/org/dromara/hutool/swing/img/ImgUtilTest.java @@ -21,10 +21,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import javax.imageio.ImageIO; -import java.awt.Color; -import java.awt.Font; -import java.awt.Image; -import java.awt.Rectangle; +import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; @@ -95,11 +92,7 @@ public class ImgUtilTest { ImgUtil.pressText(// FileUtil.file("d:/test/2.jpg"), // FileUtil.file("d:/test/2_result.png"), // - "版权所有", Color.RED, // - new Font("黑体", Font.BOLD, 100), // - 0, // - 0, // - 1f); + DisplayText.of("版权所有", Color.RED, new Font("黑体", Font.BOLD, 100), new Point(0, 0), 1f)); } @Test