File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
micropython/modules/pngdec Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ int32_t pngdec_seek_callback(PNGFILE *png, int32_t p) {
96
96
void pngdec_open_helper (_PNG_obj_t *self) {
97
97
int result = -1 ;
98
98
99
- if (mp_obj_is_str_or_bytes (self->file )){
99
+ if (mp_obj_is_str (self->file )){
100
100
GET_STR_DATA_LEN (self->file , str, str_len);
101
101
102
102
result = self->png ->open (
@@ -188,10 +188,16 @@ MICROPY_EVENT_POLL_HOOK
188
188
uint8_t i = 0 ;
189
189
if (pDraw->iBpp == 8 ) {
190
190
i = *pixel++;
191
- } else {
192
- i = pixel[x / 2 ] ;
191
+ } else if (pDraw-> iBpp == 4 ) {
192
+ i = * pixel;
193
193
i >>= (x & 0b1 ) ? 0 : 4 ;
194
194
i &= 0xf ;
195
+ if (x & 1 ) pixel++;
196
+ } else {
197
+ i = *pixel;
198
+ i >>= 6 - ((x & 0b11 ) << 1 );
199
+ i &= 0x3 ;
200
+ if ((x & 0b11 ) == 0b11 ) pixel++;
195
201
}
196
202
if (x < target->source .x || x >= target->source .x + target->source .w ) continue ;
197
203
// grab the colour from the palette
You can’t perform that action at this time.
0 commit comments