summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
authorGeorge Waters <gwatersdev@gmail.com>2020-05-22 16:28:09 -0400
committerGeorge Waters <gwatersdev@gmail.com>2020-05-22 16:28:09 -0400
commitf078055f592e01269b1a7648cd05af06b4cc81b5 (patch)
tree6937f9b939768c88b8740cbe9a16925dbaa4c3c9 /shared-module
parent16ffc731f3c64b36a486a27d87b10742cf5bb4ba (diff)
Use mp_int_t for setting pixelbuf slice indices
When handling negative steps, start and stop need to be mp_int_t so they can be checked against a potential negative value during the for loop used to set the slice values.
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/_pixelbuf/PixelBuf.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/shared-module/_pixelbuf/PixelBuf.c b/shared-module/_pixelbuf/PixelBuf.c
index c32544483..4c61a170d 100644
--- a/shared-module/_pixelbuf/PixelBuf.c
+++ b/shared-module/_pixelbuf/PixelBuf.c
@@ -216,16 +216,16 @@ void _pixelbuf_set_pixel(pixelbuf_pixelbuf_obj_t* self, size_t index, mp_obj_t v
_pixelbuf_set_pixel_color(self, index, r, g, b, w);
}
-void common_hal__pixelbuf_pixelbuf_set_pixels(mp_obj_t self_in, size_t start, size_t stop, mp_int_t step, mp_obj_t* values) {
+void common_hal__pixelbuf_pixelbuf_set_pixels(mp_obj_t self_in, mp_int_t start, mp_int_t stop, mp_int_t step, mp_obj_t* values) {
pixelbuf_pixelbuf_obj_t* self = native_pixelbuf(self_in);
size_t source_i = 0;
if (step > 0) {
- for (size_t target_i = start; target_i < stop; target_i += step) {
+ for (mp_int_t target_i = start; target_i < stop; target_i += step) {
_pixelbuf_set_pixel(self, target_i, values[source_i]);
source_i++;
}
- }else{
- for (size_t target_i = start; target_i >= stop; target_i += step) {
+ } else {
+ for (mp_int_t target_i = start; target_i >= stop; target_i += step) {
_pixelbuf_set_pixel(self, target_i, values[source_i]);
source_i++;
}