From b1af9cb9ef871ce4249e5a4fc280dd69b41c3fde Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Tue, 6 Sep 2016 16:48:34 +0300 Subject: [PATCH] [follow-up] Fix JBHiDPIScaledImage used for drawing. Create a delegate BufferedImage for JBHiDPIScaledImage used for drawing to meet the logic of UIUtil.drawImage(JBHiDPIScaledImage). --- .../src/com/intellij/util/JBHiDPIScaledImage.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/platform/util/src/com/intellij/util/JBHiDPIScaledImage.java b/platform/util/src/com/intellij/util/JBHiDPIScaledImage.java index 12e4837c4046..61079af757c0 100644 --- a/platform/util/src/com/intellij/util/JBHiDPIScaledImage.java +++ b/platform/util/src/com/intellij/util/JBHiDPIScaledImage.java @@ -37,10 +37,7 @@ public class JBHiDPIScaledImage extends BufferedImage { * @param type type of the created image */ public JBHiDPIScaledImage(int width, int height, int type) { - super(2 * width, 2 * height, type); - myImage = null; - myWidth = width; - myHeight = height; + this(new BufferedImage(width * 2, height * 2, type), width, height, type); } /** @@ -84,11 +81,10 @@ public class JBHiDPIScaledImage extends BufferedImage { @Override public Graphics2D createGraphics() { - assert myImage == null : "graphics should only be created for the image used for drawing"; - Graphics2D g = super.createGraphics(); - if (myImage == null) { - return new HiDPIScaledGraphics(g); + assert myImage instanceof BufferedImage : "graphics should only be created for the image used for drawing"; + if (myImage instanceof BufferedImage) { + return new HiDPIScaledGraphics(((BufferedImage)myImage).createGraphics()); } - return g; + return super.createGraphics(); } }