diff --git a/deck_original_v2.go b/deck_original_v2.go index 03d42c5..68b3bfb 100644 --- a/deck_original_v2.go +++ b/deck_original_v2.go @@ -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") } diff --git a/go.mod b/go.mod index edc8842..cbc60ba 100644 --- a/go.mod +++ b/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 ) diff --git a/go.sum b/go.sum index ada4b58..0fe1ced 100644 --- a/go.sum +++ b/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=