|
@@ -128,6 +128,7 @@ public class WatermarkUtil {
|
|
|
//设置字体
|
|
|
int fontSize = imgWidth / 30;
|
|
|
Font font = new Font("宋体", Font.BOLD, fontSize);
|
|
|
+ float registrationCodeX = imgWidth - imgWidth / 1920F * (registrationCode.length() * fontSize / 72F * 96F);
|
|
|
//创建输出流
|
|
|
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
|
|
ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(bs);
|
|
@@ -135,11 +136,11 @@ public class WatermarkUtil {
|
|
|
int markWidth = imgWidth / 4;
|
|
|
int markHeight = (imgWidth * mark.getHeight(null)) / (4 * mark.getWidth(null));
|
|
|
//组装要画的数据
|
|
|
- String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-mm-dd hh:mm:ss"));
|
|
|
+ String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"));
|
|
|
Local local = new Local(
|
|
|
workerName, 0, imgHeight - fontSize * 2,
|
|
|
now, 0, imgHeight,
|
|
|
- registrationCode, imgWidth - registrationCode.length() * fontSize / 10 * 6, imgHeight - markHeight - fontSize,
|
|
|
+ registrationCode, (int) registrationCodeX, imgHeight - markHeight - fontSize,
|
|
|
markWidth, markHeight, imgWidth - markWidth, imgHeight - markHeight,
|
|
|
multipartFile, font, new Color(42, 148, 188));
|
|
|
//调用画图片和文字的方法
|