修复Graphics2D的资源没释放问题

This commit is contained in:
Looly
2024-03-15 16:37:41 +08:00
parent 3a70158d96
commit 03a92830a6
6 changed files with 58 additions and 39 deletions

View File

@@ -1338,8 +1338,11 @@ public class ImgUtil {
final BufferedImage bimage = new BufferedImage(
img.getWidth(null), img.getHeight(null), imageType);
final Graphics2D bGr = GraphicsUtil.createGraphics(bimage, backgroundColor);
bGr.drawImage(img, 0, 0, null);
bGr.dispose();
try{
bGr.drawImage(img, 0, 0, null);
} finally {
bGr.dispose();
}
return bimage;
}