Class ColorFilterOp

java.lang.Object
cloud.opencode.base.image.color.ColorFilterOp

public final class ColorFilterOp extends Object
Color Filter Operations 颜色滤镜操作工具类

Provides artistic color filter transformations including sepia tone and color inversion.

提供艺术色彩滤镜变换,包括怀旧棕褐色调和反色。

Features | 主要功能:

  • Sepia (nostalgic brown tone) filter - 怀旧棕褐色滤镜
  • Color inversion filter (preserving alpha) - 反色滤镜(保留 Alpha 通道)

Usage Examples | 使用示例:

BufferedImage sepiaImage = ColorFilterOp.sepia(image);
BufferedImage invertedImage = ColorFilterOp.invert(image);

Performance | 性能特性:

  • Time: O(n) where n = pixel count - 时间: O(n),n 为像素数量
  • Space: O(n) for output image - 空间: O(n) 用于输出图像

Security | 安全性:

  • Thread-safe: Yes (stateless) - 线程安全: 是(无状态)
  • Null-safe: No - 空值安全: 否
Since:
JDK 25, opencode-base-image V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • sepia

      public static BufferedImage sepia(BufferedImage image)
      Apply sepia (nostalgic brown tone) filter to an image. 对图像应用怀旧棕褐色滤镜。

      Uses the standard sepia tone matrix:

      newR = clamp(0.393*R + 0.769*G + 0.189*B)
      newG = clamp(0.349*R + 0.686*G + 0.168*B)
      newB = clamp(0.272*R + 0.534*G + 0.131*B)
      

      Alpha channel is preserved.

      Alpha 通道保持不变。

      Parameters:
      image - the source image | 源图像
      Returns:
      the sepia-filtered image | 应用棕褐色滤镜后的图像
      Throws:
      NullPointerException - if image is null | 当图像为 null 时抛出
    • invert

      public static BufferedImage invert(BufferedImage image)
      Apply color inversion filter to an image. 对图像应用反色滤镜。

      Each RGB component is inverted: newVal = 255 - oldVal. Alpha channel is preserved.

      每个 RGB 分量被反转: newVal = 255 - oldVal。 Alpha 通道保持不变。

      Parameters:
      image - the source image | 源图像
      Returns:
      the color-inverted image | 反色后的图像
      Throws:
      NullPointerException - if image is null | 当图像为 null 时抛出