This commit is contained in:
Looly 2020-05-26 00:28:07 +08:00
parent 73b2f75de2
commit ac314bb14a
3 changed files with 35 additions and 4 deletions

View File

@ -0,0 +1,15 @@
package cn.hutool.core.img;
import org.junit.Assert;
import org.junit.Test;
import java.awt.Font;
public class FontUtilTest {
@Test
public void createFontTest(){
final Font font = FontUtil.createFont();
Assert.assertNotNull(font);
}
}

View File

@ -4,6 +4,9 @@ import cn.hutool.core.io.FileUtil;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import java.awt.Color;
import java.awt.Font;
public class ImgTest { public class ImgTest {
@Test @Test
@ -23,4 +26,17 @@ public class ImgTest {
public void roundTest() { public void roundTest() {
Img.from(FileUtil.file("e:/pic/face.jpg")).round(0.5).write(FileUtil.file("e:/pic/face_round.png")); Img.from(FileUtil.file("e:/pic/face.jpg")).round(0.5).write(FileUtil.file("e:/pic/face_round.png"));
} }
@Test
@Ignore
public void pressTextTest() {
Img.from(FileUtil.file("d:/test/617180969474805871.jpg"))
.setPositionBaseCentre(false)
.pressText("版权所有", Color.RED, //
new Font("黑体", Font.BOLD, 100), //
0, //
100, //
1f)
.write(FileUtil.file("d:/test/test2_result.png"));
}
} }

View File

@ -70,13 +70,13 @@ public class ImgUtilTest {
@Ignore @Ignore
public void pressTextTest() { public void pressTextTest() {
ImgUtil.pressText(// ImgUtil.pressText(//
FileUtil.file("e:/pic/face.jpg"), // FileUtil.file("d:/test/617180969474805871.jpg"), //
FileUtil.file("e:/pic/test2_result.png"), // FileUtil.file("d:/test/test2_result.png"), //
"版权所有", Color.WHITE, // "版权所有", Color.RED, //
new Font("黑体", Font.BOLD, 100), // new Font("黑体", Font.BOLD, 100), //
0, // 0, //
0, // 0, //
0.8f); 1f);
} }
@Test @Test