summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAlexander Neumann <alexander.neumann@picos-software.com>2019-10-28 14:20:06 +0100
committerGitHub <noreply@github.com>2019-10-28 14:20:06 +0100
commitc3d0012675ae01b40052a2f4cf78e7817ea1c92e (patch)
tree063a438c355a4f60889f6ac8fccda9ad26048ebc
parentTableView: Avoid flicker when updating items (diff)
parentform: abuse DPI handling for icon scaling better (diff)
downloadwireguard-windows-c3d0012675ae01b40052a2f4cf78e7817ea1c92e.tar.xz
wireguard-windows-c3d0012675ae01b40052a2f4cf78e7817ea1c92e.zip
Merge pull request #636 from zx2c4-forks/jd/icondpiabuse
form: abuse DPI handling for icon scaling better
-rw-r--r--form.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/form.go b/form.go
index 974b50f8..29f06ed5 100644
--- a/form.go
+++ b/form.go
@@ -522,18 +522,17 @@ func (fb *FormBase) SetIcon(icon Image) error {
if icon != nil {
dpi := fb.DPI()
size96dpi := icon.Size()
- scale := float64(dpi) / float64(size96dpi.Height)
- smallHeight96dpi := int(win.GetSystemMetricsForDpi(win.SM_CYSMICON, 96))
- smallDPI := int(math.Round(float64(smallHeight96dpi) * scale))
+ smallHeight := int(win.GetSystemMetricsForDpi(win.SM_CYSMICON, uint32(dpi)))
+ smallDPI := int(math.Round(float64(smallHeight) / float64(size96dpi.Height) * 96.0))
smallIcon, err := iconCache.Icon(icon, smallDPI)
if err != nil {
return err
}
hIconSmall = uintptr(smallIcon.handleForDPI(smallDPI))
- bigHeight96dpi := int(win.GetSystemMetricsForDpi(win.SM_CYICON, 96))
- bigDPI := int(math.Round(float64(bigHeight96dpi) * scale))
+ bigHeight := int(win.GetSystemMetricsForDpi(win.SM_CYICON, uint32(dpi)))
+ bigDPI := int(math.Round(float64(bigHeight) / float64(size96dpi.Height) * 96.0))
bigIcon, err := iconCache.Icon(icon, bigDPI)
if err != nil {
return err