@@ -68,7 +68,7 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self,
68
68
self -> r_bitmask = read_word (bmp_header , 27 );
69
69
self -> g_bitmask = read_word (bmp_header , 29 );
70
70
self -> b_bitmask = read_word (bmp_header , 31 );
71
-
71
+
72
72
} else { // no compression or short header means 5:5:5
73
73
self -> r_bitmask = 0x7c00 ;
74
74
self -> g_bitmask = 0x3e0 ;
@@ -114,7 +114,7 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self,
114
114
}
115
115
self -> stride = (bit_stride / 8 );
116
116
}
117
-
117
+
118
118
}
119
119
120
120
@@ -123,12 +123,13 @@ uint32_t common_hal_displayio_ondiskbitmap_get_pixel(displayio_ondiskbitmap_t *s
123
123
if (x < 0 || x >= self -> width || y < 0 || y >= self -> height ) {
124
124
return 0 ;
125
125
}
126
+
126
127
uint32_t location ;
127
128
uint8_t bytes_per_pixel = (self -> bits_per_pixel / 8 ) ? (self -> bits_per_pixel /8 ) : 1 ;
128
129
if (self -> bits_per_pixel >= 8 ){
129
- location = self -> data_offset + (self -> height - y ) * self -> stride + x * bytes_per_pixel ;
130
+ location = self -> data_offset + (self -> height - y - 1 ) * self -> stride + x * bytes_per_pixel ;
130
131
} else {
131
- location = self -> data_offset + (self -> height - y ) * self -> stride + x / 8 ;
132
+ location = self -> data_offset + (self -> height - y - 1 ) * self -> stride + x / 8 ;
132
133
}
133
134
// We don't cache here because the underlying FS caches sectors.
134
135
f_lseek (& self -> file -> fp , location );
@@ -140,15 +141,15 @@ uint32_t common_hal_displayio_ondiskbitmap_get_pixel(displayio_ondiskbitmap_t *s
140
141
uint8_t red ;
141
142
uint8_t green ;
142
143
uint8_t blue ;
143
- if (self -> bits_per_pixel == 1 ){
144
+ if (self -> bits_per_pixel == 1 ) {
144
145
uint8_t bit_offset = x %8 ;
145
146
tmp = ( pixel_data & (0x80 >> (bit_offset ))) >> (7 - bit_offset );
146
147
if (tmp == 1 ) {
147
148
return 0x00FFFFFF ;
148
149
} else {
149
150
return 0x00000000 ;
150
151
}
151
- } else if (bytes_per_pixel == 1 ){
152
+ } else if (bytes_per_pixel == 1 ) {
152
153
blue = ((self -> palette_data [pixel_data ] & 0xFF ) >> 0 );
153
154
red = ((self -> palette_data [pixel_data ] & 0xFF0000 ) >> 16 );
154
155
green = ((self -> palette_data [pixel_data ] & 0xFF00 ) >> 8 );
0 commit comments