Package com.xxl.tool.captcha
Class CaptchaTool.WaterRippleDistorted
java.lang.Object
com.xxl.tool.captcha.CaptchaTool.WaterRippleDistorted
- All Implemented Interfaces:
CaptchaTool.DistortedEngine
- Enclosing class:
- CaptchaTool
public static class CaptchaTool.WaterRippleDistorted
extends Object
implements CaptchaTool.DistortedEngine
水波纹效果
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intbilinearInterpolate(float x, float y, int nw, int ne, int sw, int se) 双线性插值(bilinear interpolation)算法,用于计算图像处理中的像素值。static intclamp(int c) 将值 x 限制在区间 [0, 255] 范围内。static intclamp(int x, int a, int b) 将值 x 限制在区间 [a, b] 范围内。static BufferedImage创建兼容的图像getDistortedImage(BufferedImage baseImage) static intgetPixel(int[] pixels, int x, int y, int width, int height) 获取像素点static int[]getRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) 获取 image 的 RGB,从 x,y 开始,w,h 大小;返回结果 RGB 数组;static voidsetRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) 设置 image 的 RGB,从 x,y 开始,w,h 大小;设置 RGB 数组;protected voidtransformInverse4water(int x, int y, float[] out, float icentreX, float icentreY, float radius2, float amplitude, float phase, float wavelength, float radius) 计算一个点(x,y)在水波纹扭曲后的新坐标waterFilter(BufferedImage src) 水波纹滤镜
-
Field Details
-
TWO_PI
public static final float TWO_PI2π,圆周率乘以2的值。- See Also:
-
-
Constructor Details
-
WaterRippleDistorted
public WaterRippleDistorted()
-
-
Method Details
-
getDistortedImage
- Specified by:
getDistortedImagein interfaceCaptchaTool.DistortedEngine
-
waterFilter
水波纹滤镜 -
transformInverse4water
protected void transformInverse4water(int x, int y, float[] out, float icentreX, float icentreY, float radius2, float amplitude, float phase, float wavelength, float radius) 计算一个点(x,y)在水波纹扭曲后的新坐标 -
getRGB
获取 image 的 RGB,从 x,y 开始,w,h 大小;返回结果 RGB 数组; -
setRGB
设置 image 的 RGB,从 x,y 开始,w,h 大小;设置 RGB 数组; -
getPixel
public static int getPixel(int[] pixels, int x, int y, int width, int height) 获取像素点 -
createCompatibleDestImage
创建兼容的图像 -
clamp
public static int clamp(int x, int a, int b) 将值 x 限制在区间 [a, b] 范围内。 -
clamp
public static int clamp(int c) 将值 x 限制在区间 [0, 255] 范围内。 -
bilinearInterpolate
public static int bilinearInterpolate(float x, float y, int nw, int ne, int sw, int se) 双线性插值(bilinear interpolation)算法,用于计算图像处理中的像素值。 1、从四个角点提取ARGB通道值(alpha透明度、红色、绿色、蓝色) 2、计算插值权重:cx = 1-x和cy = 1-y 3、对每个通道分别进行双线性插值:先在x方向上进行两次线性插值,再在y方向上对上一步结果进行线性插值 4、最后将四个通道重新组合成一个32位整数像素值返回 常用于图像变形、纹理映射等需要平滑过渡的场景,如水波纹失真效果。
-