Skip to content

Commit 9ac392c

Browse files
author
funnygeeker
committed
bug fix
1 parent 5af1b5a commit 9ac392c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/easydisplay.mpy

68 Bytes
Binary file not shown.

lib/easydisplay.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ def show(self):
114114
except AttributeError:
115115
pass
116116

117+
@staticmethod
118+
def rgb565_color(r, g, b):
119+
"""
120+
Convert red, green and blue values (0-255) into a 16-bit 565 encoding.
121+
"""
122+
return (r & 0xf8) << 8 | (g & 0xfc) << 3 | b >> 3
123+
117124
@staticmethod
118125
def _calculate_palette(color, bg_color) -> tuple:
119126
"""
@@ -686,7 +693,7 @@ def pbm(self, file, x, y, key: int = -1, show: bool = None, clear: bool = None,
686693
raise TypeError("Unsupported File Format Type.")
687694

688695
def bmp(self, file, x, y, key: int = -1, show: bool = None, clear: bool = None, invert: bool = False,
689-
color_type="RGB565", color: int = None, bg_color: int = None):
696+
color_type=None, color: int = None, bg_color: int = None):
690697
"""
691698
显示 bmp 图片
692699
@@ -753,7 +760,7 @@ def bmp(self, file, x, y, key: int = -1, show: bool = None, clear: bool = None,
753760
try:
754761
dp_color = dp.color
755762
except AttributeError:
756-
pass
763+
dp_color = self.rgb565_color
757764
dp_pixel = dp.pixel
758765
if f_read(2) == b'BM': # 检查文件头
759766
dummy = f_read(8) # 文件大小占四个字节,文件作者占四个字节,file size(4), creator bytes(4)

0 commit comments

Comments
 (0)