Skip to content

Commit 5f7b50b

Browse files
committed
Added RGB888 support to image function
1 parent a0d51a4 commit 5f7b50b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

adafruit_framebuf.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,12 @@ def image(self, img):
427427
height = self.height
428428
if self.rotation == 1 or self.rotation == 3:
429429
width, height = height, width
430-
if img.mode != "1":
430+
431+
if isinstance(self.format, RGB888Format) and img.mode != "RGB":
432+
raise ValueError("Image must be in mode RGB.")
433+
if isinstance(self.format, (MHMSBFormat, MVLSBFormat)) and img.mode != "1":
431434
raise ValueError("Image must be in mode 1.")
435+
432436
imwidth, imheight = img.size
433437
if imwidth != width or imheight != height:
434438
raise ValueError(
@@ -444,7 +448,9 @@ def image(self, img):
444448
# Iterate through the pixels
445449
for x in range(width): # yes this double loop is slow,
446450
for y in range(height): # but these displays are small!
447-
if pixels[(x, y)]:
451+
if img.mode == "RGB":
452+
self.pixel(x, y, pixels[(x, y)])
453+
elif pixels[(x, y)]:
448454
self.pixel(x, y, 1) # only write if pixel is true
449455

450456

0 commit comments

Comments
 (0)