mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
根据文字创建透明背景的PNG图片
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cn.hutool.core.img;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
@@ -146,4 +147,25 @@ public class ImgUtilTest {
|
||||
System.out.println(mainColor);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createImageTest() throws IORuntimeException, IOException {
|
||||
ImgUtil.createImage(
|
||||
"版权所有",
|
||||
new Font("黑体", Font.BOLD, 50),
|
||||
Color.WHITE,
|
||||
Color.BLACK,
|
||||
ImageIO.createImageOutputStream(new File("d:/test/createImageTest.png"))
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createTransparentImageTest() throws IORuntimeException, IOException {
|
||||
ImgUtil.createTransparentImage(
|
||||
"版权所有",
|
||||
new Font("黑体", Font.BOLD, 50),
|
||||
Color.BLACK,
|
||||
ImageIO.createImageOutputStream(new File("d:/test/createTransparentImageTest.png"))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user