File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
micropython/modules/pngdec Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -186,18 +186,23 @@ mp_event_handle_nowait();
186
186
} else if (pDraw->iPixelType == PNG_PIXEL_INDEXED) {
187
187
for (int x = 0 ; x < pDraw->iWidth ; x++) {
188
188
uint8_t i = 0 ;
189
- if (pDraw->iBpp == 8 ) {
189
+ if (pDraw->iBpp == 8 ) { // 8bpp
190
190
i = *pixel++;
191
- } else if (pDraw->iBpp == 4 ) {
191
+ } else if (pDraw->iBpp == 4 ) { // 4bpp
192
192
i = *pixel;
193
193
i >>= (x & 0b1 ) ? 0 : 4 ;
194
194
i &= 0xf ;
195
195
if (x & 1 ) pixel++;
196
- } else {
196
+ } else if (pDraw-> iBpp == 2 ) { // 2bpp
197
197
i = *pixel;
198
198
i >>= 6 - ((x & 0b11 ) << 1 );
199
199
i &= 0x3 ;
200
200
if ((x & 0b11 ) == 0b11 ) pixel++;
201
+ } else { // 1bpp
202
+ i = *pixel;
203
+ i >>= 7 - (x & 0b111 );
204
+ i &= 0b1 ;
205
+ if ((x & 0b111 ) == 0b111 ) pixel++;
201
206
}
202
207
if (x < target->source .x || x >= target->source .x + target->source .w ) continue ;
203
208
// grab the colour from the palette
@@ -243,7 +248,6 @@ mp_event_handle_nowait();
243
248
}
244
249
}
245
250
}
246
-
247
251
} else {
248
252
current_graphics->set_pen (r, g, b);
249
253
current_graphics->rectangle ({current_position.x , current_position.y , scale.x , scale.y });
You can’t perform that action at this time.
0 commit comments