|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|