Skip to content

Commit eda7816

Browse files
committed
change: Images生成验证码的时候应该考虑实际宽高
1 parent 73a1fd4 commit eda7816

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/org/nutz/img/Images.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,7 @@ public static BufferedImage createCaptcha(String content,
14391439

14401440
// 写入文字
14411441
int rx = 10;
1442-
int ry = isChinese ? 22 : 20;
1442+
int ry = isChinese ? height - 8 : height - 10;
14431443
for (int i = 0; i < content.length(); i++) {
14441444
int fontStyle = R.random(0, 3);
14451445
int fontSize = R.random(height - 10, height - 5);
@@ -1454,7 +1454,7 @@ public static BufferedImage createCaptcha(String content,
14541454
gc.drawString(content.charAt(i) + "", rx, ry);
14551455
// 反向角度
14561456
gc.rotate(-degree * Math.PI / 180, rx, ry);
1457-
rx += isChinese ? 25 : 20;
1457+
rx += (isChinese ? 5 : 0) + width / (content.length() + 2);
14581458
}
14591459

14601460
// 图像扭曲

0 commit comments

Comments
 (0)