Skip to content

Commit b59dd40

Browse files
authored
Use Pillow manipulation logic for grey-to-RGB conversion on EV3 to improve perf (#497)
1 parent 59cd74a commit b59dd40

1 file changed

Lines changed: 1 addition & 11 deletions

File tree

‎ev3dev2/display.py‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -287,16 +287,6 @@ def _img_to_rgb565_bytes(self):
287287
pixels = [self._color565(r, g, b) for (r, g, b) in self._img.getdata()]
288288
return pack('H' * len(pixels), *pixels)
289289

290-
def _color_xrgb(self, v):
291-
"""Convert red, green, blue components to a 32-bit XRGB value. Components
292-
should be values 0 to 255.
293-
"""
294-
return ((v << 16) | (v << 8) | v)
295-
296-
def _img_to_xrgb_bytes(self):
297-
pixels = [self._color_xrgb(v) for v in self._img.getdata()]
298-
return pack('I' * len(pixels), *pixels)
299-
300290
def update(self):
301291
"""
302292
Applies pending changes to the screen.
@@ -308,7 +298,7 @@ def update(self):
308298
elif self.var_info.bits_per_pixel == 16:
309299
self.mmap[:] = self._img_to_rgb565_bytes()
310300
elif self.platform == "ev3" and self.var_info.bits_per_pixel == 32:
311-
self.mmap[:] = self._img_to_xrgb_bytes()
301+
self.mmap[:] = self._img.convert("RGB").tobytes("raw", "XRGB")
312302
else:
313303
raise Exception("Not supported")
314304

0 commit comments

Comments
 (0)