Skip to content

Commit d22ccf5

Browse files
committed
deshipus optimization
1 parent 3dbc21d commit d22ccf5

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

adafruit_imageload/png.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,12 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements
111111
pixels_per_byte = 8 // depth
112112
# Adjust for Displayio.Bitmap filler to scanline at 4-byte boundry
113113
filladj = (4 - (scanline % 4)) % 4
114-
dst = 0
115114
src = 1
116-
src_b = 1
117115
if (
118116
(implementation[1][0] == 9 and implementation[1][1] < 2) or implementation[1][0] < 9
119117
) and (depth < 8 or width % 4 != 0):
120-
workaround = True
121-
else:
122-
workaround = False
123-
124-
for y in range(height):
125-
if workaround:
118+
src_b = 1
119+
for y in range(height):
126120
# Work around the bug in displayio.Bitmap
127121
# remove once CircuitPython 9.1 is no longer supported
128122
# https://github.com/adafruit/circuitpython/issues/6675
@@ -134,11 +128,14 @@ def load( # noqa: PLR0912, PLR0915, Too many branches, Too many statements
134128
(1 << depth) - 1
135129
)
136130
src_b += 1
137-
else:
131+
src += scanline + 1
132+
src_b = src
133+
else:
134+
dst = 0
135+
for y in range(height):
138136
mem[dst : dst + scanline] = data_bytes[src : src + scanline]
139137
dst += scanline + filladj
140-
src += scanline + 1
141-
src_b = src
138+
src += scanline + 1
142139
return bmp, pal
143140
# RGB, RGBA or Grayscale
144141
import displayio

0 commit comments

Comments
 (0)