mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-12-06 17:18:54 +08:00
Merge remote-tracking branch 'upstream/v7-dev' into perf/optimize-str-finder
This commit is contained in:
commit
7578350baa
@ -197,7 +197,7 @@ Hutool欢迎任何人为Hutool添砖加瓦,贡献代码,不过维护者是
|
||||
1. 注释完备,尤其每个新增的方法应按照Java文档规范标明方法说明、参数说明、返回值说明等信息,必要时请添加单元测试,如果愿意,也可以加上你的大名。
|
||||
2. Hutool的缩进按照Eclipse(~~不要跟我说IDEA多好用,维护者非常懒,学不会~~,IDEA真香,改了Eclipse快捷键后舒服多了)默认(tab)缩进,所以请遵守(不要和我争执空格与tab的问题,这是一个病人的习惯)。
|
||||
3. 新加的方法不要使用第三方库的方法,Hutool遵循无依赖原则(除非在extra模块中加方法工具)。
|
||||
4. 请pull request到`v6-dev`分支。Hutool在6.x版本后使用了新的分支:`v6-master`是主分支,表示已经发布中央库的版本,这个分支不允许pr,也不允许修改。
|
||||
4. 请pull request到`v7-dev`分支。Hutool在7.x版本后使用了新的分支:`v7-master`是主分支,表示已经发布中央库的版本,这个分支不允许pr,也不允许修改。
|
||||
|
||||
### 💞沟通说明
|
||||
|
||||
|
||||
@ -1727,7 +1727,7 @@ public class ImgUtil {
|
||||
* @since 3.1.0
|
||||
*/
|
||||
public static void write(final Image image, final File targetFile) throws IORuntimeException {
|
||||
ImgWriter.of(image, FileNameUtil.extName(targetFile)).write(targetFile);
|
||||
ImgWriter.of(image, FileNameUtil.extName(targetFile)).write(targetFile).flush();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1773,7 +1773,8 @@ public class ImgUtil {
|
||||
public static void write(final Image image, final String imageType, final ImageOutputStream output, final float quality) {
|
||||
ImgWriter.of(image, imageType)
|
||||
.setQuality(quality)
|
||||
.write(output);
|
||||
.write(output)
|
||||
.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -16,9 +16,9 @@
|
||||
|
||||
package cn.hutool.v7.swing.img;
|
||||
|
||||
import cn.hutool.v7.core.io.file.FileUtil;
|
||||
import cn.hutool.v7.core.io.IORuntimeException;
|
||||
import cn.hutool.v7.core.io.IoUtil;
|
||||
import cn.hutool.v7.core.io.file.FileUtil;
|
||||
import cn.hutool.v7.core.lang.Assert;
|
||||
|
||||
import javax.imageio.IIOImage;
|
||||
@ -28,7 +28,6 @@ import javax.imageio.ImageWriter;
|
||||
import javax.imageio.stream.ImageOutputStream;
|
||||
import java.awt.Color;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.io.File;
|
||||
@ -96,9 +95,11 @@ public class ImgWriter implements Flushable {
|
||||
*
|
||||
* @param out 写出到的目标流
|
||||
* @throws IORuntimeException IO异常
|
||||
* @return this
|
||||
*/
|
||||
public void write(final OutputStream out) throws IORuntimeException {
|
||||
public ImgWriter write(final OutputStream out) throws IORuntimeException {
|
||||
write(ImgUtil.getImageOutputStream(out));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,8 +107,9 @@ public class ImgWriter implements Flushable {
|
||||
*
|
||||
* @param targetFile 目标文件
|
||||
* @throws IORuntimeException IO异常
|
||||
* @return this
|
||||
*/
|
||||
public void write(final File targetFile) throws IORuntimeException {
|
||||
public ImgWriter write(final File targetFile) throws IORuntimeException {
|
||||
FileUtil.touch(targetFile);
|
||||
ImageOutputStream out = null;
|
||||
try {
|
||||
@ -116,14 +118,16 @@ public class ImgWriter implements Flushable {
|
||||
} finally {
|
||||
IoUtil.closeQuietly(out);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过{@link ImageWriter}写出图片到输出流
|
||||
*
|
||||
* @param output 输出的Image流{@link ImageOutputStream}, 非空
|
||||
* @return this
|
||||
*/
|
||||
public void write(final ImageOutputStream output) {
|
||||
public ImgWriter write(final ImageOutputStream output) {
|
||||
Assert.notNull(output);
|
||||
|
||||
final ImageWriter writer = this.writer;
|
||||
@ -145,14 +149,13 @@ public class ImgWriter implements Flushable {
|
||||
// FileCacheImageOutputStream会产生临时文件,此处关闭清除
|
||||
IoUtil.closeQuietly(output);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
final RenderedImage renderedImage = this.image;
|
||||
if(renderedImage instanceof BufferedImage){
|
||||
ImgUtil.flush((BufferedImage) renderedImage);
|
||||
} else if(renderedImage instanceof Image){
|
||||
if(renderedImage instanceof Image){
|
||||
ImgUtil.flush((Image) renderedImage);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user