Class ImageUtils
java.lang.Object
org.ofdrw.reader.tools.ImageUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImageclearWhiteBackground(BufferedImage in, int gray) 清除图片背景static BufferedImagecreateImage(int width, int height, boolean isTransparent) 创建图片static intgray(int r, int g, int b) 计算灰度static BufferedImagereadJB2(InputStream in) 读取JB2格式图片static BufferedImagerenderMask(BufferedImage image, BufferedImage mask) 蒙版抠图static byte[]toBytes(BufferedImage bufferedImage, String type)
-
Constructor Details
-
ImageUtils
public ImageUtils()
-
-
Method Details
-
toBytes
- Throws:
IOException
-
readJB2
读取JB2格式图片- Parameters:
in- 图片数据流- Returns:
- 图片数据
- Throws:
IOException- 图片操作异常
-
renderMask
蒙版抠图根据mask中像素的颜色将原图中的像素抠掉
- Parameters:
image- 原始图片mask- 蒙板图片- Returns:
- 扣去背景的图片对象
-
gray
public static int gray(int r, int g, int b) 计算灰度- Parameters:
r- 红色通道g- 绿色通道b- 蓝色通道- Returns:
- 灰度值
-
createImage
创建图片- Parameters:
width- 图形宽度height- 图像高度isTransparent- 是否透明- Returns:
- 图片对象
-
clearWhiteBackground
清除图片背景- Parameters:
in- 输入图片gray- 灰度阈值(0-255),图像中大于该值的像素将会被删除。- Returns:
- 清空背景的图片
-