change skip_index to skip_source_index
This commit is contained in:
parent
16d92ddd34
commit
72857994f2
|
@ -959,7 +959,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_draw_circle_obj, 0, bitmaptools_obj_draw_
|
|||
//| y1: int,
|
||||
//| x2: int,
|
||||
//| y2: int,
|
||||
//| skip_index: int,
|
||||
//| skip_source_index: int,
|
||||
//| skip_dest_index: int
|
||||
//| ) -> None:
|
||||
//| """Inserts the source_bitmap region defined by rectangular boundaries
|
||||
|
@ -975,14 +975,14 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_draw_circle_obj, 0, bitmaptools_obj_draw_
|
|||
//| :param int y1: Minimum y-value for rectangular bounding box to be copied from the source bitmap
|
||||
//| :param int x2: Maximum x-value (exclusive) for rectangular bounding box to be copied from the source bitmap
|
||||
//| :param int y2: Maximum y-value (exclusive) for rectangular bounding box to be copied from the source bitmap
|
||||
//| :param int skip_index: bitmap palette index in the source that will not be copied,
|
||||
//| :param int skip_source_index: bitmap palette index in the source that will not be copied,
|
||||
//| set to None to copy all pixels
|
||||
//| :param int skip_dest_index: bitmap palette index in the destination bitmap that will not get overwritten
|
||||
//| by the pixels from the source"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t bitmaptools_obj_blit(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum {ARG_destination, ARG_source, ARG_x, ARG_y, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_skip_index, ARG_skip_dest_index};
|
||||
enum {ARG_destination, ARG_source, ARG_x, ARG_y, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_skip_source_index, ARG_skip_dest_index};
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
|
||||
{MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
|
||||
|
@ -992,7 +992,7 @@ STATIC mp_obj_t bitmaptools_obj_blit(size_t n_args, const mp_obj_t *pos_args, mp
|
|||
{MP_QSTR_y1, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
|
||||
{MP_QSTR_x2, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to source->width
|
||||
{MP_QSTR_y2, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to source->height
|
||||
{MP_QSTR_skip_index, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
{MP_QSTR_skip_source_index, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
{MP_QSTR_skip_dest_index, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
};
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
|
@ -1045,15 +1045,15 @@ STATIC mp_obj_t bitmaptools_obj_blit(size_t n_args, const mp_obj_t *pos_args, mp
|
|||
y1 = temp;
|
||||
}
|
||||
|
||||
uint32_t skip_index;
|
||||
bool skip_index_none; // flag whether skip_value was None
|
||||
uint32_t skip_source_index;
|
||||
bool skip_source_index_none; // flag whether skip_value was None
|
||||
|
||||
if (args[ARG_skip_index].u_obj == mp_const_none) {
|
||||
skip_index = 0;
|
||||
skip_index_none = true;
|
||||
if (args[ARG_skip_source_index].u_obj == mp_const_none) {
|
||||
skip_source_index = 0;
|
||||
skip_source_index_none = true;
|
||||
} else {
|
||||
skip_index = mp_obj_get_int(args[ARG_skip_index].u_obj);
|
||||
skip_index_none = false;
|
||||
skip_source_index = mp_obj_get_int(args[ARG_skip_source_index].u_obj);
|
||||
skip_source_index_none = false;
|
||||
}
|
||||
|
||||
uint32_t skip_dest_index;
|
||||
|
@ -1067,7 +1067,7 @@ STATIC mp_obj_t bitmaptools_obj_blit(size_t n_args, const mp_obj_t *pos_args, mp
|
|||
skip_dest_index_none = false;
|
||||
}
|
||||
|
||||
common_hal_bitmaptools_blit(destination, source, x, y, x1, y1, x2, y2, skip_index, skip_index_none, skip_dest_index,
|
||||
common_hal_bitmaptools_blit(destination, source, x, y, x1, y1, x2, y2, skip_source_index, skip_source_index_none, skip_dest_index,
|
||||
skip_dest_index_none);
|
||||
|
||||
return mp_const_none;
|
||||
|
|
|
@ -71,7 +71,7 @@ void common_hal_bitmaptools_draw_circle(displayio_bitmap_t *destination,
|
|||
|
||||
void common_hal_bitmaptools_blit(displayio_bitmap_t *destination, displayio_bitmap_t *source, int16_t x, int16_t y,
|
||||
int16_t x1, int16_t y1, int16_t x2, int16_t y2,
|
||||
uint32_t skip_index, bool skip_index_none, uint32_t skip_self_index, bool skip_self_index_none);
|
||||
uint32_t skip_source_index, bool skip_source_index_none, uint32_t skip_dest_index, bool skip_dest_index_none);
|
||||
|
||||
void common_hal_bitmaptools_draw_polygon(displayio_bitmap_t *destination, void *xs, void *ys, size_t points_len, int point_size, uint32_t value, bool close);
|
||||
void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, mp_obj_t *file, int element_size, int bits_per_pixel, bool reverse_pixels_in_word, bool swap_bytes, bool reverse_rows);
|
||||
|
|
|
@ -984,7 +984,7 @@ void common_hal_bitmaptools_draw_circle(displayio_bitmap_t *destination,
|
|||
}
|
||||
|
||||
void common_hal_bitmaptools_blit(displayio_bitmap_t *destination, displayio_bitmap_t *source, int16_t x, int16_t y,
|
||||
int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t skip_index, bool skip_index_none, uint32_t skip_dest_index,
|
||||
int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t skip_source_index, bool skip_source_index_none, uint32_t skip_dest_index,
|
||||
bool skip_dest_index_none) {
|
||||
|
||||
if (destination->read_only) {
|
||||
|
@ -1034,13 +1034,13 @@ void common_hal_bitmaptools_blit(displayio_bitmap_t *destination, displayio_bitm
|
|||
if ((yd_index >= 0) && (yd_index < destination->height)) {
|
||||
uint32_t value = common_hal_displayio_bitmap_get_pixel(source, xs_index, ys_index);
|
||||
if (skip_dest_index_none) { // if skip_dest_index is none, then only check source skip
|
||||
if ((skip_index_none) || (value != skip_index)) { // write if skip_value_none is True
|
||||
if ((skip_source_index_none) || (value != skip_source_index)) { // write if skip_value_none is True
|
||||
displayio_bitmap_write_pixel(destination, xd_index, yd_index, value);
|
||||
}
|
||||
} else { // check dest_value index against skip_dest_index and skip if they match
|
||||
uint32_t dest_value = common_hal_displayio_bitmap_get_pixel(destination, xd_index, yd_index);
|
||||
if (dest_value != skip_dest_index) {
|
||||
if ((skip_index_none) || (value != skip_index)) { // write if skip_value_none is True
|
||||
if ((skip_source_index_none) || (value != skip_source_index)) { // write if skip_value_none is True
|
||||
displayio_bitmap_write_pixel(destination, xd_index, yd_index, value);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue