1
0
Fork 0
mirror of https://github.com/Luzifer/streamdeck.git synced 2024-10-18 05:04:18 +00:00

Rotate images to have them upside-up

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2019-11-21 00:52:23 +01:00
parent 40fbd11001
commit ea8d38c642
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
3 changed files with 14 additions and 1 deletions

View file

@ -8,6 +8,7 @@ import (
"image/jpeg" "image/jpeg"
"strings" "strings"
"github.com/disintegration/imaging"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sstallion/go-hid" "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 { func (d deckConfigOriginalV2) FillImage(keyIdx int, img image.Image) error {
buf := new(bytes.Buffer) 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") return errors.Wrap(err, "Unable to encode jpeg")
} }

2
go.mod
View file

@ -3,6 +3,8 @@ module github.com/Luzifer/streamdeck
go 1.13 go 1.13
require ( require (
github.com/disintegration/imaging v1.6.2
github.com/pkg/errors v0.8.1 github.com/pkg/errors v0.8.1
github.com/sstallion/go-hid v0.0.0-20190621001400-1cf4630be9f4 github.com/sstallion/go-hid v0.0.0-20190621001400-1cf4630be9f4
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8
) )

6
go.sum
View file

@ -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 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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 h1:hczfXYN39SDj4FcN5J7sgHBtJm4U7ef2nvlonn6NvVU=
github.com/sstallion/go-hid v0.0.0-20190621001400-1cf4630be9f4/go.mod h1:JwBz6izP5UGcbYDU5VGeLkqpRIpSBDPtCB5/XnVXz9Q= 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=