使用java进行画图,验证码初学

// TODO Auto-generated method stub


/*这是普通方法
* // 得到图片缓冲区
BufferedImage bi =new BufferedImage(150, 70, BufferedImage.TYPE_INT_RGB);
// 得到绘制环境
Graphics2D gs = (Graphics2D) bi.getGraphics();
// 设置颜色
gs.setColor(Color.WHITE);
// 填充背景色
gs.fillRect(0, 0, 150, 70);
// 设置图片边框颜色
gs.setColor(Color.RED);
// 设置边框
gs.drawRect(0, 0, 149, 69);
// 设置字体
gs.setFont(new Font("楷体",Font.BOLD+Font.ITALIC, 18));
// 想图片上绘制字符串
gs.drawString("helloword", 3, 50);
// 设置颜色
gs.setColor(Color.BLACK);
// 保存图片
ImageIO.write(bi, "JPEG", new FileOutputStream("F:/a.jpg"));*/

// 通过验证码包来进行操作
VerifyCode vc = new VerifyCode();
// 得到图片
BufferedImage bi = vc.getImage();
VerifyCode.output(bi, new FileOutputStream("F:/b.jpg"));

猜你喜欢

转载自blog.csdn.net/qq_34668848/article/details/80991454