类 SliderCodeUtil
- java.lang.Object
-
- demo.validate.code.slider.SliderCodeUtil
-
public class SliderCodeUtil extends Object
滑块验证工具类- 版本:
- : Created in 10:57 2018/6/25
- 作者:
- : https://blog.csdn.net/adidas74891496/article/details/106281363
-
-
构造器概要
构造器 构造器 说明 SliderCodeUtil()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static BufferedImagebase64StringToImage(String base64String)将BASE64字符串转换为图片static StringgetImageBASE64(BufferedImage image)将图片转换为BASE64static BufferedImagegetRandomImage(String path)随机获取一张图片对象static SliderCodegetSliderCodeImage(String filePath, int cutWidth, int cutHeight, int expireIn)根据传入的路径生成指定验证码图片static voidwriteImg(BufferedImage image, String file)将IMG输出为文件
-
-
-
方法详细资料
-
getSliderCodeImage
public static SliderCode getSliderCodeImage(String filePath, int cutWidth, int cutHeight, int expireIn) throws IOException
根据传入的路径生成指定验证码图片- 参数:
filePath- 文件路径cutWidth- 模板图宽度cutHeight- 模板图高度expireIn- 滑块验证码默认过期时间, 单位: 秒- 返回:
- sliderCode
- 抛出:
IOException- IOException
-
getRandomImage
public static BufferedImage getRandomImage(String path) throws IOException
随机获取一张图片对象- 参数:
path- path- 返回:
- BufferedImage
- 抛出:
IOException- IOException
-
writeImg
public static void writeImg(BufferedImage image, String file) throws Exception
将IMG输出为文件- 参数:
image- imagefile- file- 抛出:
Exception- Exception
-
getImageBASE64
public static String getImageBASE64(BufferedImage image) throws IOException
将图片转换为BASE64- 参数:
image- image- 返回:
- 图片字符串
- 抛出:
IOException- IOException
-
base64StringToImage
public static BufferedImage base64StringToImage(String base64String)
将BASE64字符串转换为图片- 参数:
base64String- base64String- 返回:
- BufferedImage
-
-