java实现滑动块验证码_java滑动拼图验证码教程

通过原图,在随机位置生成小方格,并根据小方格生成底图,底图由小方格的灰度化之后,绘制到原图上。

private Map createImg(File file, String filename) throws IOException {

BufferedImage sourceBuff = ImageIO.read(file);

int width = sourceBuff.getWidth();

int height = sourceBuff.getHeight();        //生成随机x,y

Random random = new Random();        //X轴距离右端tailoring_w 以上)  Y轴距离底部tailoring_y以上

this.location_x = random.nextInt(width - tailoring_w * 2) + tailoring_w;        this.location_y = random.nextInt(height - tailoring_h);        //裁剪小图

BufferedImage sourceSmall = cutImg(file, location_x, location_y, tailoring_w, tailoring_h);        //创建shape区域

List shapes = createSmallShape();

Shape area = shapes.get(0);

Shape bigarea = shapes.get(1);        //创建图层用于处理小图的阴影

BufferedImage bfm1 = new BufferedImage(tailoring_w, tailoring

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值