|
@@ -44,7 +44,7 @@ public class VerifyCode {
|
|
}
|
|
}
|
|
|
|
|
|
// 生成N条干扰线
|
|
// 生成N条干扰线
|
|
- for (int i = 0; i < 3; i++) {
|
|
|
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
int x1 = random.nextInt(width);
|
|
int x1 = random.nextInt(width);
|
|
int y1 = random.nextInt(height);
|
|
int y1 = random.nextInt(height);
|
|
int x2 = random.nextInt(width);
|
|
int x2 = random.nextInt(width);
|
|
@@ -62,8 +62,8 @@ public class VerifyCode {
|
|
.toString();
|
|
.toString();
|
|
|
|
|
|
graphics.setColor(new Color(0, 0, 255));
|
|
graphics.setColor(new Color(0, 0, 255));
|
|
- graphics.setFont(new Font("宋体", Font.BOLD, 22));
|
|
|
|
- graphics.drawString(verifyCode, 12, 28);
|
|
|
|
|
|
+ graphics.setFont(new Font("宋体", Font.BOLD, 26));
|
|
|
|
+ graphics.drawString(verifyCode, 12, 26);
|
|
graphics.dispose();
|
|
graphics.dispose();
|
|
|
|
|
|
Integer result;
|
|
Integer result;
|
|
@@ -130,7 +130,7 @@ public class VerifyCode {
|
|
for (int n = 1; n <= 10; n++) {
|
|
for (int n = 1; n <= 10; n++) {
|
|
Result result = VerifyCode.generateVerifyCode();
|
|
Result result = VerifyCode.generateVerifyCode();
|
|
|
|
|
|
- final String imgPath = String.format("Img_%s.jpg", n);
|
|
|
|
|
|
+ final String imgPath = String.format("Img_%s_%s.jpg", n, result.getResult());
|
|
File imgFile = new File(dir + "/" + imgPath);
|
|
File imgFile = new File(dir + "/" + imgPath);
|
|
ImageIO.write(result.getImage(), "JPEG", imgFile);
|
|
ImageIO.write(result.getImage(), "JPEG", imgFile);
|
|
System.out.println(imgPath + " \t\t " + result.getResult());
|
|
System.out.println(imgPath + " \t\t " + result.getResult());
|