| | |
| | | return new Color(r, g, b); |
| | | } |
| | | |
| | | public static void init() { |
| | | BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR); |
| | | Graphics g = image.getGraphics();// 产生Image对象的Graphics对象,改对象可以在图像上进行各种绘制操作 |
| | | g.fillRect(0, 0, width, height);//图片大小 |
| | | g.setFont(new Font("Times New Roman", Font.PLAIN, 18));//字体大小 |
| | | g.setColor(getRandColor(110, 133));//字体颜色 |
| | | // 绘制干扰线 |
| | | for (int i = 0; i <= lineSize; i++) { |
| | | drowLine(g); |
| | | } |
| | | // 绘制随机字符 |
| | | String randomString = ""; |
| | | for (int i = 1; i <= stringNum; i++) { |
| | | randomString = drowString(g, randomString, i); |
| | | } |
| | | g.dispose(); |
| | | } |
| | | |
| | | /** |
| | | * 生成随机图片 |
| | | */ |