Skip to content

Commit

Permalink
Resize icons & images with bilinear interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Feb 23, 2020
1 parent 7787ecc commit d8ca427
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion desktop_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (x Xorg) name(w xproto.Window) (string, error) {
}

func (x Xorg) icon(w xproto.Window) (image.Image, error) {
icon, err := xgraphics.FindIcon(x.util, w, 64, 64)
icon, err := xgraphics.FindIcon(x.util, w, 128, 128)
if err != nil {
log.Printf("Could not find icon for window %d.", w)
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func drawImage(img *image.RGBA, path string, size uint, x uint, y uint) error {
return err
}

icon = resize.Resize(size, size, icon, resize.Lanczos3)
icon = resize.Resize(size, size, icon, resize.Bilinear)
draw.Draw(img, image.Rect(int(x), int(y), int(x+size), int(y+size)), icon, image.Point{0, 0}, draw.Src)

return nil
Expand Down
4 changes: 3 additions & 1 deletion widget_recent_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"

"github.com/muesli/streamdeck"
"github.com/nfnt/resize"
)

type RecentWindowWidget struct {
Expand All @@ -17,7 +18,8 @@ func (w *RecentWindowWidget) Update(dev *streamdeck.Device) {
img := image.NewRGBA(image.Rect(0, 0, 72, 72))

if int(w.window) < len(recentWindows) {
draw.Draw(img, image.Rect(4, 4, 68, 68), recentWindows[w.window].Icon, image.Point{0, 0}, draw.Src)
icon := resize.Resize(64, 64, recentWindows[w.window].Icon, resize.Bilinear)
draw.Draw(img, image.Rect(4, 4, 68, 68), icon, image.Point{0, 0}, draw.Src)
}

err := dev.SetImage(w.key, img)
Expand Down

0 comments on commit d8ca427

Please sign in to comment.