package com.wf.captcha; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.OutputStream; /** *

Gif验证码类

* * @author: wuhongjun * @version:1.0 */ public class GifCaptcha extends Captcha { public GifCaptcha() { } public GifCaptcha(int width,int height){ this.width = width; this.height = height; alphas(); } public GifCaptcha(int width,int height,int len){ this(width,height); this.len = len; } public GifCaptcha(int width,int height,int len,Font font) { this(width,height,len); this.font = font; } @Override public void out(OutputStream os) { try { GifEncoder gifEncoder = new GifEncoder(); // gif编码类,这个利用了洋人写的编码类,所有类都在附件中 //生成字符 gifEncoder.start(os); gifEncoder.setQuality(180); gifEncoder.setDelay(100); gifEncoder.setRepeat(0); BufferedImage frame; char[] rands = textChar(); Color fontcolor[]=new Color[len]; for(int i=0;i>1) ; int w = width/len; g2d.setFont(font); for(int i=0;i len ? (num *r - s) : num * r; } }