diff options
author | Alexander Neumann <alexander.neumann@picos-software.com> | 2019-10-28 14:20:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-28 14:20:06 +0100 |
commit | c3d0012675ae01b40052a2f4cf78e7817ea1c92e (patch) | |
tree | 063a438c355a4f60889f6ac8fccda9ad26048ebc | |
parent | TableView: Avoid flicker when updating items (diff) | |
parent | form: abuse DPI handling for icon scaling better (diff) | |
download | wireguard-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.go | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -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 |