waveshare213v2: Avoid allocating for every row when drawing

Reuse the slice instead.
pull/39/head
Michael Hanselmann 4 years ago committed by M-A
parent 9b7814b7f9
commit 49c84dc6bb

@ -340,11 +340,12 @@ func (d *Dev) sendImage(cmd byte, dstRect image.Rectangle, src *image1bit.Vertic
eh.sendCommand(cmd) eh.sendCommand(cmd)
rows, cols := dataDimensions(d.opts) rows, cols := dataDimensions(d.opts)
for y := 0; y < rows; y++ {
data := make([]byte, cols) data := make([]byte, cols)
for y := 0; y < rows; y++ {
for x := 0; x < cols; x++ { for x := 0; x < cols; x++ {
data[x] = 0
for bit := 0; bit < 8; bit++ { for bit := 0; bit < 8; bit++ {
if src.BitAt((x*8)+bit, y) { if src.BitAt((x*8)+bit, y) {
data[x] |= 0x80 >> bit data[x] |= 0x80 >> bit

Loading…
Cancel
Save