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
    Modifier and Type
    Field
    Description
    static final float
    2π,圆周率乘以2的值。
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    bilinearInterpolate(float x, float y, int nw, int ne, int sw, int se)
    双线性插值(bilinear interpolation)算法,用于计算图像处理中的像素值。
    static int
    clamp(int c)
    将值 x 限制在区间 [0, 255] 范围内。
    static int
    clamp(int x, int a, int b)
    将值 x 限制在区间 [a, b] 范围内。
    创建兼容的图像
     
    static int
    getPixel(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 void
    setRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels)
    设置 image 的 RGB,从 x,y 开始,w,h 大小;设置 RGB 数组;
    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)在水波纹扭曲后的新坐标
    水波纹滤镜

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TWO_PI

      public static final float TWO_PI
      2π,圆周率乘以2的值。
      See Also:
  • Constructor Details

    • WaterRippleDistorted

      public WaterRippleDistorted()
  • Method Details

    • getDistortedImage

      public BufferedImage getDistortedImage(BufferedImage baseImage)
      Specified by:
      getDistortedImage in interface CaptchaTool.DistortedEngine
    • waterFilter

      public BufferedImage waterFilter(BufferedImage src)
      水波纹滤镜
    • 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

      public static int[] getRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels)
      获取 image 的 RGB,从 x,y 开始,w,h 大小;返回结果 RGB 数组;
    • setRGB

      public static void setRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels)
      设置 image 的 RGB,从 x,y 开始,w,h 大小;设置 RGB 数组;
    • getPixel

      public static int getPixel(int[] pixels, int x, int y, int width, int height)
      获取像素点
    • createCompatibleDestImage

      public static BufferedImage createCompatibleDestImage(BufferedImage src)
      创建兼容的图像
    • 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位整数像素值返回 常用于图像变形、纹理映射等需要平滑过渡的场景,如水波纹失真效果。