在内存中构建一幅图画

步骤:

// 在内存中构造一幅图片
BufferedImage img = new BufferedImage(80, 30,
                BufferedImage.TYPE_INT_RGB);
// 获得在图中的画笔
Graphics graph = img.getGraphics();
graph.setFont(new Font("黑体",Font.BOLD, 26));
graph.setColor(Color.red);

// 在图片中画上验证码
graph.drawString(“UI32”, 12, 23);

//将画好的图片发送到客户端
ImageIO.write(img, "JPG", response.getOutputStream());

 

posted on 2014-09-06 08:56  SkyGood  阅读(273)  评论(0编辑  收藏  举报