Class ImageUtils

java.lang.Object
org.ofdrw.reader.tools.ImageUtils

public class ImageUtils extends Object
图片处理工具
Since:
2021-04-10 18:31:03
Author:
qaqtutu
  • Constructor Details

    • ImageUtils

      public ImageUtils()
  • Method Details

    • toBytes

      public static byte[] toBytes(BufferedImage bufferedImage, String type) throws IOException
      Throws:
      IOException
    • readJB2

      public static BufferedImage readJB2(InputStream in) throws IOException
      读取JB2格式图片
      Parameters:
      in - 图片数据流
      Returns:
      图片数据
      Throws:
      IOException - 图片操作异常
    • renderMask

      public static BufferedImage renderMask(BufferedImage image, BufferedImage mask)
      蒙版抠图

      根据mask中像素的颜色将原图中的像素抠掉

      Parameters:
      image - 原始图片
      mask - 蒙板图片
      Returns:
      扣去背景的图片对象
    • gray

      public static int gray(int r, int g, int b)
      计算灰度
      Parameters:
      r - 红色通道
      g - 绿色通道
      b - 蓝色通道
      Returns:
      灰度值
    • createImage

      public static BufferedImage createImage(int width, int height, boolean isTransparent)
      创建图片
      Parameters:
      width - 图形宽度
      height - 图像高度
      isTransparent - 是否透明
      Returns:
      图片对象
    • clearWhiteBackground

      public static BufferedImage clearWhiteBackground(BufferedImage in, int gray)
      清除图片背景
      Parameters:
      in - 输入图片
      gray - 灰度阈值(0-255),图像中大于该值的像素将会被删除。
      Returns:
      清空背景的图片