diff --git a/platform/platform-impl/src/com/intellij/ui/AppIcon.java b/platform/platform-impl/src/com/intellij/ui/AppIcon.java index d0faa0614765..1e43c1bed57b 100644 --- a/platform/platform-impl/src/com/intellij/ui/AppIcon.java +++ b/platform/platform-impl/src/com/intellij/ui/AppIcon.java @@ -177,7 +177,8 @@ public abstract class AppIcon { int width = appImage.getWidth(null); int height = appImage.getHeight(null); - BufferedImage img = UIUtil.createImage(width, height, BufferedImage.TYPE_INT_ARGB); + // Note, appImage is retina-unaware, retrieved in device coordinate space. + BufferedImage img = UIUtil.createImage(width, height, BufferedImage.TYPE_INT_ARGB, false); Graphics2D g2d = img.createGraphics(); g2d.drawImage(appImage, null, null); myAppImage = img; @@ -335,7 +336,8 @@ public abstract class AppIcon { private AppImage createAppImage() { BufferedImage appImage = getAppImage(); assert appImage != null; - BufferedImage current = UIUtil.createImage(appImage.getWidth(), appImage.getHeight(), BufferedImage.TYPE_INT_ARGB); + // Note, appImage is retina-unaware, retrieved in device coordinate space. + BufferedImage current = UIUtil.createImage(appImage.getWidth(), appImage.getHeight(), BufferedImage.TYPE_INT_ARGB, false); Graphics2D g = current.createGraphics(); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); UIUtil.drawImage(g, appImage, 0, 0, null); diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 76c4945e0b4b..1094deacb77a 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -1779,15 +1779,49 @@ public class UIUtil { } } + /** + * Creates a HiDPI-aware BufferedImage + * + * @param width the width in user coordinate space + * @param height the height in user coordinate space + * @param type the type of the image + * + * @return a HiDPI-aware image + */ @NotNull public static BufferedImage createImage(int width, int height, int type) { - if (isRetina()) { + return createImage(width, height, type, true); + } + + /** + * Creates a HiDPI-aware or plain BufferedImage + * + * @param width the width in user or device coordinate space + * @param height the height in user or device coordinate space + * @param type the type of the image + * @param hidpiAware whether the image should be HiDPI-aware + * + * @return a HiDPI-aware or plain image + */ + @NotNull + public static BufferedImage createImage(int width, int height, int type, boolean hidpiAware) { + if (hidpiAware && isRetina()) { return RetinaImage.create(width, height, type); } //noinspection UndesirableClassUsage return new BufferedImage(width, height, type); } + /** + * Creates a BufferedImage with HiDPI-awareness matching the graphics. + * + * @param g the graphics to match + * @param width the width in user coordinate space + * @param height the height in user coordinate space + * @param type the type of the image + * + * @return an image matching the graphics + */ @NotNull public static BufferedImage createImageForGraphics(Graphics2D g, int width, int height, int type) { if (isRetina(g)) {