Package org.miaixz.bus.extra.captcha
Class GifCaptcha
java.lang.Object
org.miaixz.bus.extra.captcha.AbstractCaptcha
org.miaixz.bus.extra.captcha.GifCaptcha
- All Implemented Interfaces:
Serializable,ICaptcha
Gif验证码类
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields inherited from class org.miaixz.bus.extra.captcha.AbstractCaptcha
background, code, font, generator, height, imageBytes, interfereCount, textAlpha, width -
Constructor Summary
ConstructorsConstructorDescriptionGifCaptcha(int width, int height) 可以设置验证码宽度,高度的构造函数GifCaptcha(int width, int height, int codeCount) GifCaptcha(int width, int height, int codeCount, int interfereCount) GifCaptcha(int width, int height, int codeCount, int interfereCount, float sizeBaseHeight) 构造GifCaptcha(int width, int height, CodeGenerator generator, int interfereCount) 构造 -
Method Summary
Modifier and TypeMethodDescriptionvoid创建验证码,实现类需同时生成随机验证码字符串和验证码图片protected ImagecreateImage(String code) 根据生成的code创建验证码图片setMaxColor(int maxColor) 设置验证码字符颜色setMinColor(int minColor) 设置验证码字符颜色setQuality(int quality) 设置图像的颜色量化(转换质量 由GIF规范允许的最大256种颜色)。 低的值(最小值= 1)产生更好的颜色,但处理显著缓慢。 10是默认,并产生良好的颜色而且有以合理的速度。 值更大(大于20)不产生显著的改善速度setRepeat(int repeat) 设置GIF帧应该播放的次数。 默认是 0; 0意味着无限循环。 必须在添加的第一个图像之前被调用。Methods inherited from class org.miaixz.bus.extra.captcha.AbstractCaptcha
generateCode, getCode, getGenerator, getImage, getImageBase64, getImageBase64Data, getImageBytes, setBackground, setFont, setGenerator, setTextAlpha, verify, write, write, write
-
Constructor Details
-
GifCaptcha
public GifCaptcha(int width, int height) 可以设置验证码宽度,高度的构造函数- Parameters:
width- 验证码宽度height- 验证码高度
-
GifCaptcha
public GifCaptcha(int width, int height, int codeCount) - Parameters:
width- 验证码宽度height- 验证码高度codeCount- 验证码个数
-
GifCaptcha
public GifCaptcha(int width, int height, int codeCount, int interfereCount) - Parameters:
width- 验证码宽度height- 验证码高度codeCount- 验证码个数interfereCount- 干扰个数
-
GifCaptcha
构造- Parameters:
width- 图片宽height- 图片高generator- 验证码生成器interfereCount- 验证码干扰元素个数
-
GifCaptcha
public GifCaptcha(int width, int height, int codeCount, int interfereCount, float sizeBaseHeight) 构造- Parameters:
width- 图片宽height- 图片高codeCount- 验证码个数interfereCount- 验证码干扰元素个数sizeBaseHeight- 字体的大小 高度的倍数
-
-
Method Details
-
setQuality
设置图像的颜色量化(转换质量 由GIF规范允许的最大256种颜色)。 低的值(最小值= 1)产生更好的颜色,但处理显著缓慢。 10是默认,并产生良好的颜色而且有以合理的速度。 值更大(大于20)不产生显著的改善速度- Parameters:
quality- 大于1- Returns:
- this
-
setRepeat
设置GIF帧应该播放的次数。 默认是 0; 0意味着无限循环。 必须在添加的第一个图像之前被调用。- Parameters:
repeat- 必须大于等于0- Returns:
- this
-
setMaxColor
设置验证码字符颜色- Parameters:
maxColor- 颜色- Returns:
- this
-
setMinColor
设置验证码字符颜色- Parameters:
minColor- 颜色- Returns:
- this
-
createCode
public void createCode()Description copied from interface:ICaptcha创建验证码,实现类需同时生成随机验证码字符串和验证码图片- Specified by:
createCodein interfaceICaptcha- Overrides:
createCodein classAbstractCaptcha
-
createImage
Description copied from class:AbstractCaptcha根据生成的code创建验证码图片- Specified by:
createImagein classAbstractCaptcha- Parameters:
code- 验证码- Returns:
- Image
-