@@ -115,6 +115,10 @@ void common_hal_displayio_bitmap_insert(displayio_bitmap_t *self, int16_t x, int
115115 mp_raise_RuntimeError (translate ("Read-only object" ));
116116 }
117117
118+ // If this value is encountered in the source bitmap, it will not be copied (for text glyphs)
119+ // This should be added as an optional parameter, and if it is `None`, then all pixels are copied
120+ uint32_t skip_value = 0 ;
121+
118122 //// check for zero width, this would be a single pixel
119123 // if (x1_source == x2_source) || (y1_source == y2_source) {
120124 // return 0
@@ -140,9 +144,11 @@ void common_hal_displayio_bitmap_insert(displayio_bitmap_t *self, int16_t x, int
140144 // simplest version - use internal functions for get/set pixels
141145 for (uint16_t i = 0 ; i <= (x2 - x1 ) ; i ++ ) {
142146 for (uint16_t j = 0 ; j <= (y2 - y1 ) ; j ++ ){
143- uint16_t value = common_hal_displayio_bitmap_get_pixel (source , x1 + i , y1 + j );
144- if ( (x + i >= 0 ) && (y + j >= 0 ) && (x + i <= self -> width - 1 ) && (y + j <= self -> height - 1 ) ){
145- common_hal_displayio_bitmap_set_pixel (self , x + i , y + j , value );
147+ uint32_t value = common_hal_displayio_bitmap_get_pixel (source , x1 + i , y1 + j );
148+ if (value != skip_value ) {
149+ if ( (x + i >= 0 ) && (y + j >= 0 ) && (x + i <= self -> width - 1 ) && (y + j <= self -> height - 1 ) ){
150+ common_hal_displayio_bitmap_set_pixel (self , x + i , y + j , value );
151+ }
146152 }
147153 }
148154 }
0 commit comments