Skip to content

Commit 0e154ba

Browse files
committed
fixed: icon rendering on macOS
- scaling and resizing on macOS was not taking into account HiDPI screens
1 parent 8aa3417 commit 0e154ba

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
### Changed
1111
- renamed the plugin from `Coder Gateway` to `Gateway`
1212

13+
### Fixed
14+
- icon rendering on macOS
15+
1316
## 2.1.3 - 2022-12-09
1417

1518
### Added

src/main/kotlin/com/coder/gateway/sdk/TemplateIconDownloader.kt

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package com.coder.gateway.sdk
33
import com.coder.gateway.icons.CoderIcons
44
import com.intellij.openapi.components.Service
55
import com.intellij.openapi.components.service
6-
import com.intellij.ui.scale.ScaleContext
6+
import com.intellij.util.IconUtil
77
import com.intellij.util.ImageLoader
88
import com.intellij.util.ui.ImageUtil
9+
import org.imgscalr.Scalr
910
import java.net.URL
1011
import javax.swing.Icon
11-
import javax.swing.ImageIcon
1212

1313
@Service(Service.Level.APP)
1414
class TemplateIconDownloader {
@@ -25,10 +25,7 @@ class TemplateIconDownloader {
2525
if (url != null) {
2626
var img = ImageLoader.loadFromUrl(url)
2727
if (img != null) {
28-
if (ImageUtil.getRealHeight(img) > 32 && ImageUtil.getRealWidth(img) > 32) {
29-
img = ImageUtil.resize(img, 32, ScaleContext.create())
30-
}
31-
return ImageIcon(img)
28+
return IconUtil.toRetinaAwareIcon(Scalr.resize(ImageUtil.toBufferedImage(img), Scalr.Method.ULTRA_QUALITY, 32))
3229
}
3330
}
3431

0 commit comments

Comments
 (0)