BufferedImage image = new BufferedImage(100,50,BufferedImage.TYPE_INT_RGB);
String code = captchaProducer.createText();
System.out.println(code);
Graphics graphics =image.getGraphics();
char[] cs = code.toCharArray();
graphics.fillRect(0,0, 100, 50);
for(int i=0;i<=3;i++)
{
graphics.setColor(new Color(random.nextInt(256),random.nextInt(256),random.nextInt(256)));
graphics.setFont(new Font("微软雅黑",Font.BOLD,30));
char c=cs[i];
graphics.drawString(" "+c, i*25, 30);
}
int max=random.nextInt(15);
for(int i=0;i<max;i++)
{
graphics.setColor(new Color(random.nextInt(256),random.nextInt(256),random.nextInt(256)));
graphics.drawLine(random.nextInt(100),random.nextInt(50), random.nextInt(100), random.nextInt(50));
}
int max2=random.nextInt(15);
for(int i=0;i<max2;i++)
{
graphics.setColor(new Color(random.nextInt(256),random.nextInt(256),random.nextInt(256)));
graphics.drawOval(random.nextInt(80), random.nextInt(40), random.nextInt(5), random.nextInt(10));
}