Compare commits

...

4 Commits
main ... 5.3.x

Author SHA1 Message Date
Dan Halbert
715b8d55cc
Merge pull request #3385 from jepler/fix-unicode-above-2047
Fix decompression of unicode values above 2047
2020-09-08 23:14:18 -04:00
Jeff Epler
e82940697c Fix decompression of unicode values above 2047
Two problems: The lead byte for 3-byte sequences was wrong, and one
mid-byte was not even filled in due to a missing "++"!

Apparently this was broken ever since the first "Compress as unicode,
not bytes" commit, but I believed I'd "tested" it by running on the
Pinyin translation.

This rendered at least the Korean and Japanese translations completely
illegible, affecting 5.0 and all later releases.
2020-09-08 20:58:48 -05:00
Scott Shawcroft
365d69e831
Merge pull request #3142 from rhooper/pixelbuf_rgbw_fix_5.3.x
Allow setting RGBW pixels with RGB tuples
2020-07-10 17:42:40 -07:00
Roy Hooper
dd53e9a2bd Allow setting RGBW pixels with RGB tuples 2020-07-10 14:03:57 -04:00
2 changed files with 12 additions and 10 deletions

View File

@ -147,18 +147,11 @@ void _pixelbuf_parse_color(pixelbuf_pixelbuf_obj_t* self, mp_obj_t color, uint8_
*r = value >> 16 & 0xff;
*g = (value >> 8) & 0xff;
*b = value & 0xff;
// Int colors can't set white directly so convert to white when all components are equal.
if (!byteorder->is_dotstar && byteorder->bpp == 4 && byteorder->has_white && *r == *g && *r == *b) {
*w = *r;
*r = 0;
*g = 0;
*b = 0;
}
} else {
mp_obj_t *items;
size_t len;
mp_obj_get_array(color, &len, &items);
if (len != byteorder->bpp && !byteorder->is_dotstar) {
if (len < 3 || len > 4) {
mp_raise_ValueError_varg(translate("Expected tuple of length %d, got %d"), byteorder->bpp, len);
}
@ -171,8 +164,17 @@ void _pixelbuf_parse_color(pixelbuf_pixelbuf_obj_t* self, mp_obj_t color, uint8_
} else {
*w = mp_obj_get_int_truncated(items[PIXEL_W]);
}
return;
}
}
// Int colors can't set white directly so convert to white when all components are equal.
// Also handles RGBW values assigned an RGB tuple.
if (!byteorder->is_dotstar && byteorder->bpp == 4 && byteorder->has_white && *r == *g && *r == *b) {
*w = *r;
*r = 0;
*g = 0;
*b = 0;
}
}
void _pixelbuf_set_pixel_color(pixelbuf_pixelbuf_obj_t* self, size_t index, uint8_t r, uint8_t g, uint8_t b, uint8_t w) {

View File

@ -51,8 +51,8 @@ STATIC int put_utf8(char *buf, int u) {
*buf = 0b10000000 | (u & 0b00111111);
return 2;
} else { // u <= 0xffff)
*buf++ = 0b11000000 | (u >> 12);
*buf = 0b10000000 | ((u >> 6) & 0b00111111);
*buf++ = 0b11100000 | (u >> 12);
*buf++ = 0b10000000 | ((u >> 6) & 0b00111111);
*buf = 0b10000000 | (u & 0b00111111);
return 3;
}