From 82319138ee7918b26e4583f54842b1374b68bef2 Mon Sep 17 00:00:00 2001 From: Starryi Date: Sat, 18 Sep 2021 16:47:40 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-58697=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E3=80=91frm=E4=B8=BB=E9=A2=98body=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E8=AE=BE=E7=BD=AE=E9=BB=98=E8=AE=A4=E5=9B=BE=E7=89=87?= =?UTF-8?q?=EF=BC=8C=E7=BC=A9=E7=95=A5=E5=9B=BE=E5=8F=98=E9=BB=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 绘制缩略图前,Graphics.clearRect导致对画布进行设置全部失效, 需要在clear后重新设置默认白色背景 【改动思路】 同上 --- .../design/mainframe/theme/TemplateThemePreviewPane.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java index 19885763cc..c302cf1ad8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java @@ -48,9 +48,6 @@ public abstract class TemplateThemePreviewPane extends int height = getHeight(); try { - // 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image, - // 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0) - // 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图 image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = image.createGraphics(); // 创建一个支持透明背景的buffer image @@ -58,8 +55,6 @@ public abstract class TemplateThemePreviewPane extends g2d.dispose(); g2d = image.createGraphics(); - g2d.fillRect(0, 0, width, height); - g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.clipRect(0, 0, width, height); @@ -80,6 +75,9 @@ public abstract class TemplateThemePreviewPane extends @Override public void paintComponent(Graphics g) { g.clearRect(0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT); + // 添加个默认白色,否则因为上面的clearRect导致无背景时会出现黑色 + g.setColor(Color.WHITE); + g.fillRect(0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT); paintBackground((Graphics2D) g); }