Skip to content

Commit

Permalink
Merge pull request #84 from deshipu/bug-74
Browse files Browse the repository at this point in the history
Fix #74
  • Loading branch information
FoamyGuy authored Aug 3, 2024
2 parents fa649ac + 3495299 commit b3f0d1e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion adafruit_imageload/png.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,19 @@ def load(
for y in range(height):
dst = y * scanline
src = y * (scanline + 1) + 1
mem[dst : dst + scanline] = data_bytes[src : src + scanline]
if depth < 8:
# Work around the bug in displayio.Bitmap
# https://github.com/adafruit/circuitpython/issues/6675
pixels_per_byte = 8 // depth
for x in range(0, width, pixels_per_byte):
byte = data_bytes[src]
for pixel in range(pixels_per_byte):
bmp[x + pixel, y] = (
byte >> ((pixels_per_byte - pixel - 1) * depth)
) & ((1 << depth) - 1)
src += 1
else:
mem[dst : dst + scanline] = data_bytes[src : src + scanline]
return bmp, pal
# RGB, RGBA or Grayscale
import displayio
Expand Down

0 comments on commit b3f0d1e

Please sign in to comment.