Fix pixel / bitmap order in README.md

Avoid buffer overflow
pull/121/head
Graeme Winter 2021-04-08 09:36:02 +01:00
rodzic e1027353ab
commit d17cd858b5
2 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -88,7 +88,7 @@ picoscroll.set_pixels(image)
### show_bitmap_1d ### show_bitmap_1d
Show a view of a bitmap stored as the 7 least significant bits of Show a view of a bitmap stored as the 7 least significant bits of
bytes in a `bytearray`, top-down. Individual pixels are set to bytes in a `bytearray`, bottom-up. Individual pixels are set to
`brightness` based on individual bit values, with the view defined by `brightness` based on individual bit values, with the view defined by
the offset and the width of the scroll (i.e. 17 columns). Changes will the offset and the width of the scroll (i.e. 17 columns). Changes will
not be visible until `update()` is called. not be visible until `update()` is called.

Wyświetl plik

@ -111,7 +111,7 @@ mp_obj_t picoscroll_show_bitmap_1d(mp_obj_t bitmap_obj, mp_obj_t brightness_obj,
for (int x = 0; x < width; x++) { for (int x = 0; x < width; x++) {
int k = offset + x; int k = offset + x;
if ((k >= 0) && (k <= length)) { if ((k >= 0) && (k < length)) {
unsigned char col = values[k]; unsigned char col = values[k];
for (int y = 0; y < height; y++) { for (int y = 0; y < height; y++) {
int val = brightness * ((col >> y) & 1); int val = brightness * ((col >> y) & 1);