【fix sonar】RandImageUtil文件

This commit is contained in:
梁琦涛
2023-04-04 10:36:05 +08:00
parent 0dbb449138
commit a13e2d8e8c
@@ -82,7 +82,6 @@ public class RandImageUtil {
base64 = base64.replace("\n", "").replace("\r", "");//删除 \r\n
//写到指定位置
//ImageIO.write(bufferedImage, "png", new File(""));
return BASE64_PRE+base64;
}
@@ -99,7 +98,6 @@ public class RandImageUtil {
// graphics.setColor(getRandColor(100, 200)); // ---2
graphics.drawRect(0, 0, WIDTH - 1, HEIGHT - 1);
// final Random random = new Random();
// 随机产生干扰线,使图象中的认证码不易被其它程序探测到
for (int i = 0; i < COUNT; i++) {
graphics.setColor(getRandColor(150, 200)); // ---3
@@ -114,11 +112,9 @@ public class RandImageUtil {
for (int i = 0; i < resultCode.length(); i++) {
// 将认证码显示到图象中,调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
// graphics.setColor(new Color(20 + random.nextInt(130), 20 + random
// .nextInt(130), 20 + random.nextInt(130)));
// 设置字体颜色
graphics.setColor(Color.BLACK);
// 设置字体样式
// graphics.setFont(new Font("Arial Black", Font.ITALIC, 18));
graphics.setFont(new Font("Times New Roman", Font.BOLD, 24));
// 设置字符,字符间距,上边距
graphics.drawString(String.valueOf(resultCode.charAt(i)), (23 * i) + 8, 26);
@@ -133,7 +129,6 @@ public class RandImageUtil {
}
private static Color getRandColor(int fc, int bc) { // 取得给定范围随机颜色
// final Random random = new Random();
if (fc > 255) {
fc = 255;
}