@@ -53,6 +53,8 @@ def read_header(self):
53
53
self .data_size = int .from_bytes (f .read (4 ), 'little' )
54
54
f .seek (46 )
55
55
self .colors = int .from_bytes (f .read (4 ), 'little' )
56
+ def color555 (self , rgb ):
57
+ return (rgb & 0x001F ) << 11 | (rgb & 0x0700 ) | (rgb & 0x0060 ) << 1 | 0x20 | (rgb & 0xF800 ) >> 11
56
58
57
59
def draw (self , disp , x = 0 , y = 0 ):
58
60
print ("{:d}x{:d} image" .format (self .width , self .height ))
@@ -72,7 +74,7 @@ def draw(self, disp, x=0, y=0):
72
74
if (line_size - i ) < self .bpp // 8 :
73
75
break
74
76
if self .bpp == 16 :
75
- color = line_data [i ] << 8 | line_data [i + 1 ]
77
+ color = self . color555 ( line_data [i ] << 8 | line_data [i + 1 ])
76
78
if self .bpp == 24 :
77
79
color = color565 (line_data [i + 2 ], line_data [i + 1 ], line_data [i ])
78
80
current_line_data = current_line_data + struct .pack (">H" , color )
@@ -81,9 +83,4 @@ def draw(self, disp, x=0, y=0):
81
83
disp .set_window (0 , 0 , disp .width , disp .height )
82
84
83
85
bitmap = BMP ("/ra8875_blinka.bmp" )
84
- print (display .width )
85
- print (display .height )
86
- print (bitmap .width )
87
- print (bitmap .height )
88
- bitmap .draw (display , (display .width // 2 ) - (bitmap .width // 2 ),
89
- (display .height // 2 ) - (bitmap .height // 2 ))
86
+ bitmap .draw (display , (display .width // 2 ) - (bitmap .width // 2 ), (display .height // 2 ) - (bitmap .height // 2 ))
0 commit comments