Package org.miaixz.bus.extra.image
Class ImageWriter
java.lang.Object
org.miaixz.bus.extra.image.ImageWriter
- All Implemented Interfaces:
Flushable
图片写出封装
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidflush()static ImageWriter创建图片写出器static ImageWriter创建图片写出器setQuality(float quality) 设置写出质量,数字为0~1(不包括0和1)表示质量压缩比,除此数字外设置表示不压缩void写出图像为目标文件扩展名对应的格式voidwrite(OutputStream out) 写出图像:GIF=JPG、GIF=PNG、PNG=JPG、PNG=GIF(X)、BMP=PNG 此方法并不关闭流voidwrite(ImageOutputStream output) 通过ImageWriter写出图片到输出流
-
Constructor Details
-
ImageWriter
构造- Parameters:
image-ImageimageType- 图片类型(图片扩展名),null表示使用RGB模式(JPG)
-
-
Method Details
-
of
创建图片写出器- Parameters:
image- 图片imageType- 图片类型(图片扩展名),null表示使用RGB模式(JPG)backgroundColor- 背景色Color,null表示黑色或透明- Returns:
ImgWriter
-
of
创建图片写出器- Parameters:
image- 图片imageType- 图片类型(图片扩展名),null表示使用RGB模式(JPG)- Returns:
ImgWriter
-
setQuality
设置写出质量,数字为0~1(不包括0和1)表示质量压缩比,除此数字外设置表示不压缩- Parameters:
quality- 写出质量,数字为0~1(不包括0和1)表示质量压缩比,除此数字外设置表示不压缩- Returns:
- this
-
write
写出图像:GIF=JPG、GIF=PNG、PNG=JPG、PNG=GIF(X)、BMP=PNG 此方法并不关闭流- Parameters:
out- 写出到的目标流- Throws:
org.miaixz.bus.core.lang.exception.InternalException- IO异常
-
write
写出图像为目标文件扩展名对应的格式- Parameters:
destFile- 目标文件- Throws:
org.miaixz.bus.core.lang.exception.InternalException- IO异常
-
write
通过ImageWriter写出图片到输出流- Parameters:
output- 输出的Image流ImageOutputStream, 非空
-
flush
public void flush()
-