Skip to content

Use bitmap subscr #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion adafruit_imageload/bmp/indexed.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ def load(file, width, height, data_start, colors, color_depth, *, bitmap=None, p

file.seek(data_start - colors * 4)
for value in range(colors):
palette[value] = file.read(4)
c_bytes = file.read(4)
# Need to swap red & blue bytes (bytes 0 and 2)
palette[value] = bytes(b''.join([c_bytes[2:3],
c_bytes[1:2],
c_bytes[0:1],
c_bytes[3:1]]))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

faster?

            palette[value] = bytes([c_bytes[2], c_bytes[1], c_bytes[0], c_bytes[3]]) 


if bitmap:
minimum_color_depth = 1
Expand Down
17 changes: 17 additions & 0 deletions examples/imageload_colorwheel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import board
import displayio
import adafruit_imageload

display = board.DISPLAY

bitmap, palette = adafruit_imageload.load("images/color_wheel.bmp",
bitmap=displayio.Bitmap,
palette=displayio.Palette)

tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette)

group = displayio.Group()
group.append(tile_grid)
display.show(group)
while True:
pass
Binary file added examples/images/color_wheel.bmp
Binary file not shown.