根据文字创建透明背景的PNG图片

This commit is contained in:
hiqiuyi
2022-07-25 12:01:26 +08:00
parent 630ed4775f
commit 0f2fc9f3ae
2 changed files with 44 additions and 14 deletions

View File

@@ -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"))
);
}
}