Skip to content

Commit 58de611

Browse files
authored
Merge pull request #4278 from kmatch98/blit_self
fix two off by one errors
2 parents 538cd7e + 3afc269 commit 58de611

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

shared-module/displayio/Bitmap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,14 @@ void common_hal_displayio_bitmap_blit(displayio_bitmap_t *self, int16_t x, int16
130130
// simplest version - use internal functions for get/set pixels
131131
for (int16_t i=0; i < (x2-x1); i++) {
132132

133-
const int xs_index = x_reverse ? ( (x2 - 1) - i ) : x1+i; // x-index into the source bitmap
134-
const int xd_index = x_reverse ? ((x + (x2-x1)) - i ) : x+i; // x-index into the destination bitmap
133+
const int xs_index = x_reverse ? ( (x2) - i - 1) : x1+i; // x-index into the source bitmap
134+
const int xd_index = x_reverse ? ((x + (x2-x1)) - i - 1) : x+i; // x-index into the destination bitmap
135135

136136
if ( (xd_index >= 0) && (xd_index < self->width) ) {
137137
for (int16_t j=0; j < (y2-y1) ; j++){
138138

139-
const int ys_index = y_reverse ? ( (y2 - 1) - j ) : y1+j ; // y-index into the source bitmap
140-
const int yd_index = y_reverse ? ((y + (y2-y1)) - j ) : y+j ; // y-index into the destination bitmap
139+
const int ys_index = y_reverse ? ( (y2 ) - j - 1) : y1+j ; // y-index into the source bitmap
140+
const int yd_index = y_reverse ? ((y + (y2-y1)) - j - 1) : y+j ; // y-index into the destination bitmap
141141

142142
if ((yd_index >= 0) && (yd_index < self->height) ) {
143143
uint32_t value = common_hal_displayio_bitmap_get_pixel(source, xs_index, ys_index);

0 commit comments

Comments
 (0)