Skip to content

Commit 7cf463d

Browse files
authored
Merge pull request #1 from siehputz/use_bitmap_subscr
Use bitmap subscr
2 parents 852d0f8 + 5e27e00 commit 7cf463d

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

adafruit_imageload/bmp/indexed.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ def load(file, width, height, data_start, colors, color_depth, *, bitmap=None, p
4747

4848
file.seek(data_start - colors * 4)
4949
for value in range(colors):
50-
palette[value] = file.read(4)
50+
c_bytes = file.read(4)
51+
# Need to swap red & blue bytes (bytes 0 and 2)
52+
palette[value] = bytes(b''.join([c_bytes[2:3],
53+
c_bytes[1:2],
54+
c_bytes[0:1],
55+
c_bytes[3:1]]))
5156

5257
if bitmap:
5358
minimum_color_depth = 1

examples/imageload_colorwheel.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import board
2+
import displayio
3+
import adafruit_imageload
4+
5+
display = board.DISPLAY
6+
7+
bitmap, palette = adafruit_imageload.load("images/color_wheel.bmp",
8+
bitmap=displayio.Bitmap,
9+
palette=displayio.Palette)
10+
11+
tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette)
12+
13+
group = displayio.Group()
14+
group.append(tile_grid)
15+
display.show(group)
16+
while True:
17+
pass

examples/images/color_wheel.bmp

76.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)