Skip to content

Commit cfda5cc

Browse files
committed
Fixed red/green color issue in indexed.py and added an example and image
to show the complete color wheel.
1 parent 852d0f8 commit cfda5cc

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

adafruit_imageload/bmp/indexed.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ 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 = file.read(4)
51+
# Need to swap red & green bytes (bytes 0 and 2)
52+
d = bytes(b''.join([c[2:3],c[1:2],c[0:1],c[3:1]]))
53+
palette[value] = d
5154

5255
if bitmap:
5356
minimum_color_depth = 1

examples/code.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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", bitmap=displayio.Bitmap, palette=displayio.Palette)
8+
9+
tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette)
10+
11+
group = displayio.Group()
12+
group.append(tile_grid)
13+
display.show(group)
14+
while True:
15+
pass

examples/imageload_colorwheel.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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", bitmap=displayio.Bitmap, palette=displayio.Palette)
8+
9+
tile_grid = displayio.TileGrid(bitmap, pixel_shader=palette)
10+
11+
group = displayio.Group()
12+
group.append(tile_grid)
13+
display.show(group)
14+
while True:
15+
pass

examples/images/color_wheel.bmp

76.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)