send alpha, if needed

This commit is contained in:
Norwin Roosen 2020-12-28 09:33:52 +01:00
parent 0ede282b73
commit 8f18af72f7
No known key found for this signature in database
GPG Key ID: 24BC059DE24C43A3
1 changed files with 9 additions and 4 deletions

View File

@ -45,10 +45,15 @@ func commandsFromImage(img *image.NRGBA, offset image.Point) (cmds commands) {
if c.A == 0 {
continue
}
// @incomplete: also send alpha? -> bandwidth tradeoff
// @speed: this sprintf call is quite slow..
cmd := fmt.Sprintf("PX %d %d %.2x%.2x%.2x\n",
x+offset.X, y+offset.Y, c.R, c.G, c.B)
var cmd string
if c.A != 255 {
cmd = fmt.Sprintf("PX %d %d %.2x%.2x%.2x%.2x\n",
x+offset.X, y+offset.Y, c.R, c.G, c.B, c.A)
} else {
// @speed: this sprintf call is quite slow..
cmd = fmt.Sprintf("PX %d %d %.2x%.2x%.2x\n",
x+offset.X, y+offset.Y, c.R, c.G, c.B)
}
cmds[numCmds] = []byte(cmd)
numCmds++
}