@@ -196,7 +196,8 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val
196196//| y1: int,
197197//| x2: int,
198198//| y2: int,
199- //| skip_index: int
199+ //| skip_index: int,
200+ //| skip_self_index: int
200201//| ) -> None:
201202//| """Inserts the source_bitmap region defined by rectangular boundaries
202203//| (x1,y1) and (x2,y2) into the bitmap at the specified (x,y) location.
@@ -211,10 +212,12 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val
211212//| :param int x2: Maximum x-value (exclusive) for rectangular bounding box to be copied from the source bitmap
212213//| :param int y2: Maximum y-value (exclusive) for rectangular bounding box to be copied from the source bitmap
213214//| :param int skip_index: bitmap palette index in the source that will not be copied,
214- //| set to None to copy all pixels"""
215+ //| set to None to copy all pixels
216+ //| :param int skip_self_index: bitmap palette index in the self bitmap that will not get overwritten
217+ //| by the pixels from the source"""
215218//| ...
216219STATIC mp_obj_t displayio_bitmap_obj_blit (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
217- enum {ARG_x , ARG_y , ARG_source , ARG_x1 , ARG_y1 , ARG_x2 , ARG_y2 , ARG_skip_index };
220+ enum {ARG_x , ARG_y , ARG_source , ARG_x1 , ARG_y1 , ARG_x2 , ARG_y2 , ARG_skip_index , ARG_skip_self_index };
218221 static const mp_arg_t allowed_args [] = {
219222 {MP_QSTR_x , MP_ARG_REQUIRED | MP_ARG_INT , {.u_obj = MP_OBJ_NULL } },
220223 {MP_QSTR_y , MP_ARG_REQUIRED | MP_ARG_INT , {.u_obj = MP_OBJ_NULL } },
@@ -224,6 +227,7 @@ STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_arg
224227 {MP_QSTR_x2 , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = mp_const_none } }, // None convert to source->width
225228 {MP_QSTR_y2 , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = mp_const_none } }, // None convert to source->height
226229 {MP_QSTR_skip_index , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = mp_const_none } },
230+ {MP_QSTR_skip_self_index , MP_ARG_OBJ | MP_ARG_KW_ONLY , {.u_obj = mp_const_none } },
227231 };
228232 mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
229233 mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
@@ -283,7 +287,19 @@ STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_arg
283287 skip_index_none = false;
284288 }
285289
286- common_hal_displayio_bitmap_blit (self , x , y , source , x1 , y1 , x2 , y2 , skip_index , skip_index_none );
290+ uint32_t skip_self_index ;
291+ bool skip_self_index_none ; // flag whether skip_self_value was None
292+
293+ if (args [ARG_skip_self_index ].u_obj == mp_const_none ) {
294+ skip_self_index = 0 ;
295+ skip_self_index_none = true;
296+ } else {
297+ skip_self_index = mp_obj_get_int (args [ARG_skip_self_index ].u_obj );
298+ skip_self_index_none = false;
299+ }
300+
301+ common_hal_displayio_bitmap_blit (self , x , y , source , x1 , y1 , x2 , y2 , skip_index , skip_index_none , skip_self_index ,
302+ skip_self_index_none );
287303
288304 return mp_const_none ;
289305}
0 commit comments