mirror of
https://github.com/Luzifer/streamdeck.git
synced 2024-12-20 09:41:19 +00:00
Rotate images to have them upside-up
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
40fbd11001
commit
ea8d38c642
3 changed files with 14 additions and 1 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"image/jpeg"
|
||||
"strings"
|
||||
|
||||
"github.com/disintegration/imaging"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sstallion/go-hid"
|
||||
)
|
||||
|
@ -58,7 +59,11 @@ func (d deckConfigOriginalV2) FillColor(keyIdx int, col color.RGBA) error {
|
|||
|
||||
func (d deckConfigOriginalV2) FillImage(keyIdx int, img image.Image) error {
|
||||
buf := new(bytes.Buffer)
|
||||
if err := jpeg.Encode(buf, img, &jpeg.Options{Quality: 95}); err != nil {
|
||||
|
||||
// We need to rotate the image or it will be presented upside down
|
||||
rimg := imaging.Rotate180(img)
|
||||
|
||||
if err := jpeg.Encode(buf, rimg, &jpeg.Options{Quality: 95}); err != nil {
|
||||
return errors.Wrap(err, "Unable to encode jpeg")
|
||||
}
|
||||
|
||||
|
|
2
go.mod
2
go.mod
|
@ -3,6 +3,8 @@ module github.com/Luzifer/streamdeck
|
|||
go 1.13
|
||||
|
||||
require (
|
||||
github.com/disintegration/imaging v1.6.2
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/sstallion/go-hid v0.0.0-20190621001400-1cf4630be9f4
|
||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8
|
||||
)
|
||||
|
|
6
go.sum
6
go.sum
|
@ -1,4 +1,10 @@
|
|||
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
|
||||
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/sstallion/go-hid v0.0.0-20190621001400-1cf4630be9f4 h1:hczfXYN39SDj4FcN5J7sgHBtJm4U7ef2nvlonn6NvVU=
|
||||
github.com/sstallion/go-hid v0.0.0-20190621001400-1cf4630be9f4/go.mod h1:JwBz6izP5UGcbYDU5VGeLkqpRIpSBDPtCB5/XnVXz9Q=
|
||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U=
|
||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
|
|
Loading…
Reference in a new issue