Browse Source

REPORT-58697 【主题切换】frm主题body背景设置默认图片,缩略图变黑

【问题原因】
绘制缩略图前,Graphics.clearRect导致对画布进行设置全部失效,
需要在clear后重新设置默认白色背景

【改动思路】
同上
research/11.0
Starryi 3 years ago
parent
commit
82319138ee
  1. 8
      designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java

8
designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemePreviewPane.java

@ -48,9 +48,6 @@ public abstract class TemplateThemePreviewPane<T extends TemplateTheme> extends
int height = getHeight(); int height = getHeight();
try { 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); image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = image.createGraphics(); Graphics2D g2d = image.createGraphics();
// 创建一个支持透明背景的buffer image // 创建一个支持透明背景的buffer image
@ -58,8 +55,6 @@ public abstract class TemplateThemePreviewPane<T extends TemplateTheme> extends
g2d.dispose(); g2d.dispose();
g2d = image.createGraphics(); g2d = image.createGraphics();
g2d.fillRect(0, 0, width, height);
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.clipRect(0, 0, width, height); g2d.clipRect(0, 0, width, height);
@ -80,6 +75,9 @@ public abstract class TemplateThemePreviewPane<T extends TemplateTheme> extends
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
g.clearRect(0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT); g.clearRect(0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT);
// 添加个默认白色,否则因为上面的clearRect导致无背景时会出现黑色
g.setColor(Color.WHITE);
g.fillRect(0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT);
paintBackground((Graphics2D) g); paintBackground((Graphics2D) g);
} }

Loading…
Cancel
Save