Merge remote-tracking branch 'adafruit/main' into merge-micropython-v1.19.1
This commit is contained in:
commit
6851faacaa
|
@ -6,7 +6,7 @@ msgstr ""
|
||||||
"Project-Id-Version: \n"
|
"Project-Id-Version: \n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2021-01-04 12:55-0600\n"
|
"POT-Creation-Date: 2021-01-04 12:55-0600\n"
|
||||||
"PO-Revision-Date: 2023-07-19 21:06+0000\n"
|
"PO-Revision-Date: 2023-08-12 10:50+0000\n"
|
||||||
"Last-Translator: Luc <some_physics@live.com>\n"
|
"Last-Translator: Luc <some_physics@live.com>\n"
|
||||||
"Language: de_DE\n"
|
"Language: de_DE\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
|
@ -1501,7 +1501,7 @@ msgstr "Kein laufende Aufzeichnung"
|
||||||
|
|
||||||
#: shared-module/usb/core/Device.c
|
#: shared-module/usb/core/Device.c
|
||||||
msgid "No configuration set"
|
msgid "No configuration set"
|
||||||
msgstr ""
|
msgstr "Keine Konfiguration vorhanden"
|
||||||
|
|
||||||
#: shared-bindings/_bleio/PacketBuffer.c
|
#: shared-bindings/_bleio/PacketBuffer.c
|
||||||
msgid "No connection: length cannot be determined"
|
msgid "No connection: length cannot be determined"
|
||||||
|
@ -2112,7 +2112,7 @@ msgstr "Zu viele Kanäle im sample."
|
||||||
|
|
||||||
#: shared-module/displayio/__init__.c
|
#: shared-module/displayio/__init__.c
|
||||||
msgid "Too many display busses; forgot displayio.release_displays() ?"
|
msgid "Too many display busses; forgot displayio.release_displays() ?"
|
||||||
msgstr ""
|
msgstr "Zu viele Display-Busse, displayio.release_displays() vergessen?"
|
||||||
|
|
||||||
#: shared-module/displayio/__init__.c
|
#: shared-module/displayio/__init__.c
|
||||||
msgid "Too many displays"
|
msgid "Too many displays"
|
||||||
|
@ -2849,7 +2849,7 @@ msgstr "Kann Instanz nicht erstellen"
|
||||||
|
|
||||||
#: extmod/ulab/code/ndarray.c
|
#: extmod/ulab/code/ndarray.c
|
||||||
msgid "cannot delete array elements"
|
msgid "cannot delete array elements"
|
||||||
msgstr ""
|
msgstr "Array-Elemente können nicht gelöscht werden"
|
||||||
|
|
||||||
#: py/runtime.c
|
#: py/runtime.c
|
||||||
msgid "cannot import name %q"
|
msgid "cannot import name %q"
|
||||||
|
@ -3318,7 +3318,7 @@ msgstr "inline assembler muss eine function sein"
|
||||||
|
|
||||||
#: extmod/ulab/code/numpy/vector.c
|
#: extmod/ulab/code/numpy/vector.c
|
||||||
msgid "input and output dimensions differ"
|
msgid "input and output dimensions differ"
|
||||||
msgstr ""
|
msgstr "Eingabe- und Ausgabedimensionen unterscheiden sich"
|
||||||
|
|
||||||
#: extmod/ulab/code/numpy/vector.c
|
#: extmod/ulab/code/numpy/vector.c
|
||||||
msgid "input and output shapes differ"
|
msgid "input and output shapes differ"
|
||||||
|
@ -3764,7 +3764,7 @@ msgstr "nicht implementiert für komplexe dtype"
|
||||||
|
|
||||||
#: extmod/ulab/code/numpy/bitwise.c
|
#: extmod/ulab/code/numpy/bitwise.c
|
||||||
msgid "not supported for input types"
|
msgid "not supported for input types"
|
||||||
msgstr ""
|
msgstr "nicht unterstützt für Eingabetypen"
|
||||||
|
|
||||||
#: extmod/ulab/code/numpy/create.c
|
#: extmod/ulab/code/numpy/create.c
|
||||||
msgid "number of points must be at least 2"
|
msgid "number of points must be at least 2"
|
||||||
|
@ -3924,7 +3924,7 @@ msgstr ""
|
||||||
|
|
||||||
#: extmod/ulab/code/numpy/vector.c
|
#: extmod/ulab/code/numpy/vector.c
|
||||||
msgid "out keyword is not supported for function"
|
msgid "out keyword is not supported for function"
|
||||||
msgstr ""
|
msgstr "out-Schlüsselwort wird nicht unterstützt für Funktion"
|
||||||
|
|
||||||
#: extmod/ulab/code/utils/utils.c
|
#: extmod/ulab/code/utils/utils.c
|
||||||
msgid "out must be a float dense array"
|
msgid "out must be a float dense array"
|
||||||
|
@ -3932,11 +3932,11 @@ msgstr "Ausgabe muss ein floatdichtes Array sein"
|
||||||
|
|
||||||
#: extmod/ulab/code/numpy/vector.c
|
#: extmod/ulab/code/numpy/vector.c
|
||||||
msgid "out must be an ndarray"
|
msgid "out must be an ndarray"
|
||||||
msgstr ""
|
msgstr "out muss ein ndarray sein"
|
||||||
|
|
||||||
#: extmod/ulab/code/numpy/vector.c
|
#: extmod/ulab/code/numpy/vector.c
|
||||||
msgid "out must be of float dtype"
|
msgid "out must be of float dtype"
|
||||||
msgstr ""
|
msgstr "out muss vom Typ dtype sein"
|
||||||
|
|
||||||
#: shared-bindings/bitmaptools/__init__.c
|
#: shared-bindings/bitmaptools/__init__.c
|
||||||
msgid "out of range of target"
|
msgid "out of range of target"
|
||||||
|
|
|
@ -7,7 +7,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"PO-Revision-Date: 2023-08-06 17:45+0000\n"
|
"PO-Revision-Date: 2023-08-14 01:48+0000\n"
|
||||||
"Last-Translator: Andi Chandler <andi@gowling.com>\n"
|
"Last-Translator: Andi Chandler <andi@gowling.com>\n"
|
||||||
"Language-Team: none\n"
|
"Language-Team: none\n"
|
||||||
"Language: en_GB\n"
|
"Language: en_GB\n"
|
||||||
|
@ -266,19 +266,19 @@ msgstr "%q=%q"
|
||||||
|
|
||||||
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
||||||
msgid "%q[%u] shifts in more bits than pin count"
|
msgid "%q[%u] shifts in more bits than pin count"
|
||||||
msgstr ""
|
msgstr "%q[%u] shifts in more bits than pin count"
|
||||||
|
|
||||||
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
||||||
msgid "%q[%u] shifts out more bits than pin count"
|
msgid "%q[%u] shifts out more bits than pin count"
|
||||||
msgstr ""
|
msgstr "%q[%u] shifts out more bits than pin count"
|
||||||
|
|
||||||
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
||||||
msgid "%q[%u] uses extra pin"
|
msgid "%q[%u] uses extra pin"
|
||||||
msgstr ""
|
msgstr "%q[%u] uses extra pin"
|
||||||
|
|
||||||
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
||||||
msgid "%q[%u] waits on input outside of count"
|
msgid "%q[%u] waits on input outside of count"
|
||||||
msgstr ""
|
msgstr "%q[%u] waits on input outside of count"
|
||||||
|
|
||||||
#: ports/espressif/common-hal/espidf/__init__.c
|
#: ports/espressif/common-hal/espidf/__init__.c
|
||||||
#, c-format
|
#, c-format
|
||||||
|
@ -1370,31 +1370,31 @@ msgstr "Mismatched swap flag"
|
||||||
|
|
||||||
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
||||||
msgid "Missing first_in_pin. %q[%u] reads pin(s)"
|
msgid "Missing first_in_pin. %q[%u] reads pin(s)"
|
||||||
msgstr ""
|
msgstr "Missing first_in_pin. %q[%u] reads pin(s)"
|
||||||
|
|
||||||
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
||||||
msgid "Missing first_in_pin. %q[%u] shifts in from pin(s)"
|
msgid "Missing first_in_pin. %q[%u] shifts in from pin(s)"
|
||||||
msgstr ""
|
msgstr "Missing first_in_pin. %q[%u] shifts in from pin(s)"
|
||||||
|
|
||||||
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
||||||
msgid "Missing first_in_pin. %q[%u] waits based on pin"
|
msgid "Missing first_in_pin. %q[%u] waits based on pin"
|
||||||
msgstr ""
|
msgstr "Missing first_in_pin. %q[%u] waits based on pin"
|
||||||
|
|
||||||
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
||||||
msgid "Missing first_out_pin. %q[%u] shifts out to pin(s)"
|
msgid "Missing first_out_pin. %q[%u] shifts out to pin(s)"
|
||||||
msgstr ""
|
msgstr "Missing first_out_pin. %q[%u] shifts out to pin(s)"
|
||||||
|
|
||||||
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
||||||
msgid "Missing first_out_pin. %q[%u] writes pin(s)"
|
msgid "Missing first_out_pin. %q[%u] writes pin(s)"
|
||||||
msgstr ""
|
msgstr "Missing first_out_pin. %q[%u] writes pin(s)"
|
||||||
|
|
||||||
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
||||||
msgid "Missing first_set_pin. %q[%u] sets pin(s)"
|
msgid "Missing first_set_pin. %q[%u] sets pin(s)"
|
||||||
msgstr ""
|
msgstr "Missing first_set_pin. %q[%u] sets pin(s)"
|
||||||
|
|
||||||
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
||||||
msgid "Missing jmp_pin. %q[%u] jumps on pin"
|
msgid "Missing jmp_pin. %q[%u] jumps on pin"
|
||||||
msgstr ""
|
msgstr "Missing jmp_pin. %q[%u] jumps on pin"
|
||||||
|
|
||||||
#: shared-bindings/busio/UART.c shared-bindings/displayio/Group.c
|
#: shared-bindings/busio/UART.c shared-bindings/displayio/Group.c
|
||||||
msgid "Must be a %q subclass."
|
msgid "Must be a %q subclass."
|
||||||
|
|
|
@ -11,6 +11,7 @@ EXTERNAL_FLASH_DEVICES = GD25Q16C
|
||||||
LONGINT_IMPL = MPZ
|
LONGINT_IMPL = MPZ
|
||||||
|
|
||||||
CIRCUITPY__EVE = 1
|
CIRCUITPY__EVE = 1
|
||||||
|
CIRCUITPY_FLOPPYIO = 0
|
||||||
CIRCUITPY_SYNTHIO = 0
|
CIRCUITPY_SYNTHIO = 0
|
||||||
|
|
||||||
# We don't have room for the fonts for terminalio for certain languages,
|
# We don't have room for the fonts for terminalio for certain languages,
|
||||||
|
|
|
@ -72,6 +72,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO48) },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO48) },
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_IO48), MP_ROM_PTR(&pin_GPIO48) },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_IO48), MP_ROM_PTR(&pin_GPIO48) },
|
||||||
|
|
||||||
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_SD_CS),MP_ROM_PTR(&pin_GPIO21) },
|
||||||
|
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) },
|
||||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) },
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) },
|
||||||
|
|
||||||
|
|
|
@ -273,6 +273,28 @@ STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args
|
||||||
}
|
}
|
||||||
|
|
||||||
MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_rotozoom_obj, 0, bitmaptools_obj_rotozoom);
|
MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_rotozoom_obj, 0, bitmaptools_obj_rotozoom);
|
||||||
|
|
||||||
|
//| class BlendMode:
|
||||||
|
//| """The blend mode for `alphablend` to operate use"""
|
||||||
|
//|
|
||||||
|
//| Normal: BlendMode
|
||||||
|
//| """Blend with equal parts of the two source bitmaps"""
|
||||||
|
//|
|
||||||
|
//| Screen: BlendMode
|
||||||
|
//| """Blend based on the value in each color channel. The result keeps the lighter colors and discards darker colors."""
|
||||||
|
//|
|
||||||
|
MAKE_ENUM_VALUE(bitmaptools_blendmode_type, bitmaptools_blendmode, Normal, BITMAPTOOLS_BLENDMODE_NORMAL);
|
||||||
|
MAKE_ENUM_VALUE(bitmaptools_blendmode_type, bitmaptools_blendmode, Screen, BITMAPTOOLS_BLENDMODE_SCREEN);
|
||||||
|
|
||||||
|
MAKE_ENUM_MAP(bitmaptools_blendmode) {
|
||||||
|
MAKE_ENUM_MAP_ENTRY(bitmaptools_blendmode, Normal),
|
||||||
|
MAKE_ENUM_MAP_ENTRY(bitmaptools_blendmode, Screen),
|
||||||
|
};
|
||||||
|
STATIC MP_DEFINE_CONST_DICT(bitmaptools_blendmode_locals_dict, bitmaptools_blendmode_locals_table);
|
||||||
|
|
||||||
|
MAKE_PRINTER(bitmaptools, bitmaptools_blendmode);
|
||||||
|
MAKE_ENUM_TYPE(bitmaptools, BlendMode, bitmaptools_blendmode);
|
||||||
|
|
||||||
// requires at least 2 arguments (destination bitmap and source bitmap)
|
// requires at least 2 arguments (destination bitmap and source bitmap)
|
||||||
|
|
||||||
//| def alphablend(
|
//| def alphablend(
|
||||||
|
@ -282,6 +304,9 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_rotozoom_obj, 0, bitmaptools_obj_rotozoom
|
||||||
//| colorspace: displayio.Colorspace,
|
//| colorspace: displayio.Colorspace,
|
||||||
//| factor1: float = 0.5,
|
//| factor1: float = 0.5,
|
||||||
//| factor2: Optional[float] = None,
|
//| factor2: Optional[float] = None,
|
||||||
|
//| blendmode: Optional[BlendMode] = BlendMode.Normal,
|
||||||
|
//| skip_source1_index: Union[int, None] = None,
|
||||||
|
//| skip_source2_index: Union[int, None] = None,
|
||||||
//| ) -> None:
|
//| ) -> None:
|
||||||
//| """Alpha blend the two source bitmaps into the destination.
|
//| """Alpha blend the two source bitmaps into the destination.
|
||||||
//|
|
//|
|
||||||
|
@ -294,13 +319,16 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_rotozoom_obj, 0, bitmaptools_obj_rotozoom
|
||||||
//| :param float factor1: The proportion of bitmap 1 to mix in
|
//| :param float factor1: The proportion of bitmap 1 to mix in
|
||||||
//| :param float factor2: The proportion of bitmap 2 to mix in. If specified as `None`, ``1-factor1`` is used. Usually the proportions should sum to 1.
|
//| :param float factor2: The proportion of bitmap 2 to mix in. If specified as `None`, ``1-factor1`` is used. Usually the proportions should sum to 1.
|
||||||
//| :param displayio.Colorspace colorspace: The colorspace of the bitmaps. They must all have the same colorspace. Only the following colorspaces are permitted: ``L8``, ``RGB565``, ``RGB565_SWAPPED``, ``BGR565`` and ``BGR565_SWAPPED``.
|
//| :param displayio.Colorspace colorspace: The colorspace of the bitmaps. They must all have the same colorspace. Only the following colorspaces are permitted: ``L8``, ``RGB565``, ``RGB565_SWAPPED``, ``BGR565`` and ``BGR565_SWAPPED``.
|
||||||
|
//| :param bitmaptools.BlendMode blendmode: The blend mode to use. Default is Normal.
|
||||||
|
//| :param int skip_source1_index: Bitmap palette or luminance index in source_bitmap_1 that will not be blended, set to None to blend all pixels
|
||||||
|
//| :param int skip_source2_index: Bitmap palette or luminance index in source_bitmap_2 that will not be blended, set to None to blend all pixels
|
||||||
//|
|
//|
|
||||||
//| For the L8 colorspace, the bitmaps must have a bits-per-value of 8.
|
//| For the L8 colorspace, the bitmaps must have a bits-per-value of 8.
|
||||||
//| For the RGB colorspaces, they must have a bits-per-value of 16."""
|
//| For the RGB colorspaces, they must have a bits-per-value of 16."""
|
||||||
//|
|
//|
|
||||||
|
|
||||||
STATIC mp_obj_t bitmaptools_alphablend(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
STATIC mp_obj_t bitmaptools_alphablend(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||||
enum {ARG_dest_bitmap, ARG_source_bitmap_1, ARG_source_bitmap_2, ARG_colorspace, ARG_factor_1, ARG_factor_2};
|
enum {ARG_dest_bitmap, ARG_source_bitmap_1, ARG_source_bitmap_2, ARG_colorspace, ARG_factor_1, ARG_factor_2, ARG_blendmode, ARG_skip_source1_index, ARG_skip_source2_index};
|
||||||
|
|
||||||
static const mp_arg_t allowed_args[] = {
|
static const mp_arg_t allowed_args[] = {
|
||||||
{MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = NULL}},
|
{MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = NULL}},
|
||||||
|
@ -309,6 +337,9 @@ STATIC mp_obj_t bitmaptools_alphablend(size_t n_args, const mp_obj_t *pos_args,
|
||||||
{MP_QSTR_colorspace, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = NULL}},
|
{MP_QSTR_colorspace, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = NULL}},
|
||||||
{MP_QSTR_factor_1, MP_ARG_OBJ, {.u_obj = MP_ROM_NONE}},
|
{MP_QSTR_factor_1, MP_ARG_OBJ, {.u_obj = MP_ROM_NONE}},
|
||||||
{MP_QSTR_factor_2, MP_ARG_OBJ, {.u_obj = MP_ROM_NONE}},
|
{MP_QSTR_factor_2, MP_ARG_OBJ, {.u_obj = MP_ROM_NONE}},
|
||||||
|
{MP_QSTR_blendmode, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = (void *)&bitmaptools_blendmode_Normal_obj}},
|
||||||
|
{MP_QSTR_skip_source1_index, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||||
|
{MP_QSTR_skip_source2_index, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||||
};
|
};
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
@ -321,6 +352,7 @@ STATIC mp_obj_t bitmaptools_alphablend(size_t n_args, const mp_obj_t *pos_args,
|
||||||
mp_float_t factor2 = (args[ARG_factor_2].u_obj == mp_const_none) ? 1 - factor1 : mp_obj_get_float(args[ARG_factor_2].u_obj);
|
mp_float_t factor2 = (args[ARG_factor_2].u_obj == mp_const_none) ? 1 - factor1 : mp_obj_get_float(args[ARG_factor_2].u_obj);
|
||||||
|
|
||||||
displayio_colorspace_t colorspace = (displayio_colorspace_t)cp_enum_value(&displayio_colorspace_type, args[ARG_colorspace].u_obj, MP_QSTR_colorspace);
|
displayio_colorspace_t colorspace = (displayio_colorspace_t)cp_enum_value(&displayio_colorspace_type, args[ARG_colorspace].u_obj, MP_QSTR_colorspace);
|
||||||
|
bitmaptools_blendmode_t blendmode = (bitmaptools_blendmode_t)cp_enum_value(&bitmaptools_blendmode_type, args[ARG_blendmode].u_obj, MP_QSTR_blendmode);
|
||||||
|
|
||||||
if (destination->width != source1->width
|
if (destination->width != source1->width
|
||||||
|| destination->height != source1->height
|
|| destination->height != source1->height
|
||||||
|
@ -352,7 +384,30 @@ STATIC mp_obj_t bitmaptools_alphablend(size_t n_args, const mp_obj_t *pos_args,
|
||||||
mp_raise_ValueError(translate("Unsupported colorspace"));
|
mp_raise_ValueError(translate("Unsupported colorspace"));
|
||||||
}
|
}
|
||||||
|
|
||||||
common_hal_bitmaptools_alphablend(destination, source1, source2, colorspace, factor1, factor2);
|
uint32_t skip_source1_index;
|
||||||
|
bool skip_source1_index_none; // flag whether skip_value was None
|
||||||
|
|
||||||
|
if (args[ARG_skip_source1_index].u_obj == mp_const_none) {
|
||||||
|
skip_source1_index = 0;
|
||||||
|
skip_source1_index_none = true;
|
||||||
|
} else {
|
||||||
|
skip_source1_index = mp_obj_get_int(args[ARG_skip_source1_index].u_obj);
|
||||||
|
skip_source1_index_none = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t skip_source2_index;
|
||||||
|
bool skip_source2_index_none; // flag whether skip_self_value was None
|
||||||
|
|
||||||
|
if (args[ARG_skip_source2_index].u_obj == mp_const_none) {
|
||||||
|
skip_source2_index = 0;
|
||||||
|
skip_source2_index_none = true;
|
||||||
|
} else {
|
||||||
|
skip_source2_index = mp_obj_get_int(args[ARG_skip_source2_index].u_obj);
|
||||||
|
skip_source2_index_none = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
common_hal_bitmaptools_alphablend(destination, source1, source2, colorspace, factor1, factor2, blendmode, skip_source1_index,
|
||||||
|
skip_source1_index_none, skip_source2_index, skip_source2_index_none);
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
@ -1088,6 +1143,7 @@ STATIC const mp_rom_map_elem_t bitmaptools_module_globals_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR_draw_circle), MP_ROM_PTR(&bitmaptools_draw_circle_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_draw_circle), MP_ROM_PTR(&bitmaptools_draw_circle_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_blit), MP_ROM_PTR(&bitmaptools_blit_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_blit), MP_ROM_PTR(&bitmaptools_blit_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_dither), MP_ROM_PTR(&bitmaptools_dither_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_dither), MP_ROM_PTR(&bitmaptools_dither_obj) },
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_BlendMode), MP_ROM_PTR(&bitmaptools_blendmode_type) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_DitherAlgorithm), MP_ROM_PTR(&bitmaptools_dither_algorithm_type) },
|
{ MP_ROM_QSTR(MP_QSTR_DitherAlgorithm), MP_ROM_PTR(&bitmaptools_dither_algorithm_type) },
|
||||||
};
|
};
|
||||||
STATIC MP_DEFINE_CONST_DICT(bitmaptools_module_globals, bitmaptools_module_globals_table);
|
STATIC MP_DEFINE_CONST_DICT(bitmaptools_module_globals, bitmaptools_module_globals_table);
|
||||||
|
|
|
@ -40,6 +40,13 @@ typedef enum {
|
||||||
|
|
||||||
extern const mp_obj_type_t bitmaptools_dither_algorithm_type;
|
extern const mp_obj_type_t bitmaptools_dither_algorithm_type;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
BITMAPTOOLS_BLENDMODE_NORMAL, BITMAPTOOLS_BLENDMODE_SCREEN,
|
||||||
|
} bitmaptools_blendmode_t;
|
||||||
|
|
||||||
|
extern const mp_obj_type_t bitmaptools_blendmode_type;
|
||||||
|
extern const cp_enum_obj_t bitmaptools_blendmode_Normal_obj;
|
||||||
|
|
||||||
void common_hal_bitmaptools_rotozoom(displayio_bitmap_t *self, int16_t ox, int16_t oy,
|
void common_hal_bitmaptools_rotozoom(displayio_bitmap_t *self, int16_t ox, int16_t oy,
|
||||||
int16_t dest_clip0_x, int16_t dest_clip0_y,
|
int16_t dest_clip0_x, int16_t dest_clip0_y,
|
||||||
int16_t dest_clip1_x, int16_t dest_clip1_y,
|
int16_t dest_clip1_x, int16_t dest_clip1_y,
|
||||||
|
@ -78,6 +85,7 @@ void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, mp_obj_t *file, i
|
||||||
void common_hal_bitmaptools_arrayblit(displayio_bitmap_t *self, void *data, int element_size, int x1, int y1, int x2, int y2, bool skip_specified, uint32_t skip_index);
|
void common_hal_bitmaptools_arrayblit(displayio_bitmap_t *self, void *data, int element_size, int x1, int y1, int x2, int y2, bool skip_specified, uint32_t skip_index);
|
||||||
void common_hal_bitmaptools_dither(displayio_bitmap_t *dest_bitmap, displayio_bitmap_t *source_bitmap, displayio_colorspace_t colorspace, bitmaptools_dither_algorithm_t algorithm);
|
void common_hal_bitmaptools_dither(displayio_bitmap_t *dest_bitmap, displayio_bitmap_t *source_bitmap, displayio_colorspace_t colorspace, bitmaptools_dither_algorithm_t algorithm);
|
||||||
|
|
||||||
void common_hal_bitmaptools_alphablend(displayio_bitmap_t *destination, displayio_bitmap_t *source1, displayio_bitmap_t *source2, displayio_colorspace_t colorspace, mp_float_t factor1, mp_float_t factor2);
|
void common_hal_bitmaptools_alphablend(displayio_bitmap_t *destination, displayio_bitmap_t *source1, displayio_bitmap_t *source2, displayio_colorspace_t colorspace, mp_float_t factor1, mp_float_t factor2,
|
||||||
|
bitmaptools_blendmode_t blendmode, uint32_t skip_source1_index, bool skip_source1_index_none, uint32_t skip_source2_index, bool skip_source2_index_none);
|
||||||
|
|
||||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BITMAPTOOLS__INIT__H
|
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BITMAPTOOLS__INIT__H
|
||||||
|
|
|
@ -861,26 +861,53 @@ void common_hal_bitmaptools_dither(displayio_bitmap_t *dest_bitmap, displayio_bi
|
||||||
displayio_bitmap_set_dirty_area(dest_bitmap, &a);
|
displayio_bitmap_set_dirty_area(dest_bitmap, &a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_bitmaptools_alphablend(displayio_bitmap_t *dest, displayio_bitmap_t *source1, displayio_bitmap_t *source2, displayio_colorspace_t colorspace, mp_float_t factor1, mp_float_t factor2) {
|
void common_hal_bitmaptools_alphablend(displayio_bitmap_t *dest, displayio_bitmap_t *source1, displayio_bitmap_t *source2, displayio_colorspace_t colorspace, mp_float_t factor1, mp_float_t factor2,
|
||||||
|
bitmaptools_blendmode_t blendmode, uint32_t skip_source1_index, bool skip_source1_index_none, uint32_t skip_source2_index, bool skip_source2_index_none) {
|
||||||
displayio_area_t a = {0, 0, dest->width, dest->height, NULL};
|
displayio_area_t a = {0, 0, dest->width, dest->height, NULL};
|
||||||
displayio_bitmap_set_dirty_area(dest, &a);
|
displayio_bitmap_set_dirty_area(dest, &a);
|
||||||
|
|
||||||
int ifactor1 = (int)(factor1 * 256);
|
int ifactor1 = (int)(factor1 * 256);
|
||||||
int ifactor2 = (int)(factor2 * 256);
|
int ifactor2 = (int)(factor2 * 256);
|
||||||
|
bool blend_source1, blend_source2;
|
||||||
|
|
||||||
if (colorspace == DISPLAYIO_COLORSPACE_L8) {
|
if (colorspace == DISPLAYIO_COLORSPACE_L8) {
|
||||||
for (int y = 0; y < dest->height; y++) {
|
for (int y = 0; y < dest->height; y++) {
|
||||||
uint8_t *dptr = (uint8_t *)(dest->data + y * dest->stride);
|
uint8_t *dptr = (uint8_t *)(dest->data + y * dest->stride);
|
||||||
uint8_t *sptr1 = (uint8_t *)(source1->data + y * source1->stride);
|
uint8_t *sptr1 = (uint8_t *)(source1->data + y * source1->stride);
|
||||||
uint8_t *sptr2 = (uint8_t *)(source2->data + y * source2->stride);
|
uint8_t *sptr2 = (uint8_t *)(source2->data + y * source2->stride);
|
||||||
|
int pixel;
|
||||||
for (int x = 0; x < dest->width; x++) {
|
for (int x = 0; x < dest->width; x++) {
|
||||||
// This is round(l1*f1 + l2*f2) & clip to range in fixed-point
|
blend_source1 = skip_source1_index_none || *sptr1 != (uint8_t)skip_source1_index;
|
||||||
int pixel = (*sptr1++ *ifactor1 + *sptr2++ *ifactor2 + 128) / 256;
|
blend_source2 = skip_source2_index_none || *sptr2 != (uint8_t)skip_source2_index;
|
||||||
|
if (blend_source1 && blend_source2) {
|
||||||
|
// Premultiply by the alpha factor
|
||||||
|
int sda = *sptr1++ *ifactor1;
|
||||||
|
int sca = *sptr2++ *ifactor2;
|
||||||
|
// Blend
|
||||||
|
int blend;
|
||||||
|
if (blendmode == BITMAPTOOLS_BLENDMODE_SCREEN) {
|
||||||
|
blend = sca + sda - (sca * sda / 65536);
|
||||||
|
} else {
|
||||||
|
blend = sca + sda * (256 - ifactor2) / 256;
|
||||||
|
}
|
||||||
|
// Divide by the alpha factor
|
||||||
|
pixel = (blend / (ifactor1 + ifactor2 - ifactor1 * ifactor2 / 256));
|
||||||
|
} else if (blend_source1) {
|
||||||
|
// Apply iFactor1 to source1 only
|
||||||
|
pixel = *sptr1++ *ifactor1 / 256;
|
||||||
|
} else if (blend_source2) {
|
||||||
|
// Apply iFactor2 to source1 only
|
||||||
|
pixel = *sptr2++ *ifactor2 / 256;
|
||||||
|
} else {
|
||||||
|
// Use the destination value
|
||||||
|
pixel = *dptr;
|
||||||
|
}
|
||||||
*dptr++ = MIN(255, MAX(0, pixel));
|
*dptr++ = MIN(255, MAX(0, pixel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bool swap = (colorspace == DISPLAYIO_COLORSPACE_RGB565_SWAPPED) || (colorspace == DISPLAYIO_COLORSPACE_BGR565_SWAPPED);
|
bool swap = (colorspace == DISPLAYIO_COLORSPACE_RGB565_SWAPPED) || (colorspace == DISPLAYIO_COLORSPACE_BGR565_SWAPPED);
|
||||||
|
uint16_t pixel;
|
||||||
for (int y = 0; y < dest->height; y++) {
|
for (int y = 0; y < dest->height; y++) {
|
||||||
uint16_t *dptr = (uint16_t *)(dest->data + y * dest->stride);
|
uint16_t *dptr = (uint16_t *)(dest->data + y * dest->stride);
|
||||||
uint16_t *sptr1 = (uint16_t *)(source1->data + y * source1->stride);
|
uint16_t *sptr1 = (uint16_t *)(source1->data + y * source1->stride);
|
||||||
|
@ -897,25 +924,69 @@ void common_hal_bitmaptools_alphablend(displayio_bitmap_t *dest, displayio_bitma
|
||||||
const int g_mask = 0x07e0;
|
const int g_mask = 0x07e0;
|
||||||
const int b_mask = 0x001f; // (or r mask, if BGR)
|
const int b_mask = 0x001f; // (or r mask, if BGR)
|
||||||
|
|
||||||
// This is round(r1*f1 + r2*f2) & clip to range in fixed-point
|
blend_source1 = skip_source1_index_none || spix1 != (int)skip_source1_index;
|
||||||
// but avoiding shifting it down to start at bit 0
|
blend_source2 = skip_source2_index_none || spix2 != (int)skip_source2_index;
|
||||||
int r = ((spix1 & r_mask) * ifactor1
|
|
||||||
+ (spix2 & r_mask) * ifactor2 + r_mask / 2) / 256;
|
|
||||||
r = MIN(r_mask, MAX(0, r)) & r_mask;
|
|
||||||
|
|
||||||
// ditto
|
if (blend_source1 && blend_source2) {
|
||||||
int g = ((spix1 & g_mask) * ifactor1
|
// Blend based on the SVG alpha compositing specs
|
||||||
+ (spix2 & g_mask) * ifactor2 + g_mask / 2) / 256;
|
// https://dev.w3.org/SVG/modules/compositing/master/#alphaCompositing
|
||||||
g = MIN(g_mask, MAX(0, g)) & g_mask;
|
|
||||||
|
|
||||||
int b = ((spix1 & b_mask) * ifactor1
|
int ifactor_blend = ifactor1 + ifactor2 - ifactor1 * ifactor2 / 256;
|
||||||
+ (spix2 & b_mask) * ifactor2 + b_mask / 2) / 256;
|
|
||||||
b = MIN(b_mask, MAX(0, b)) & b_mask;
|
|
||||||
|
|
||||||
uint16_t pixel = r | g | b;
|
// Premultiply the colors by the alpha factor
|
||||||
if (swap) {
|
int red_dca = ((spix1 & r_mask) >> 8) * ifactor1;
|
||||||
pixel = __builtin_bswap16(pixel);
|
int grn_dca = ((spix1 & g_mask) >> 3) * ifactor1;
|
||||||
|
int blu_dca = ((spix1 & b_mask) << 3) * ifactor1;
|
||||||
|
|
||||||
|
int red_sca = ((spix2 & r_mask) >> 8) * ifactor2;
|
||||||
|
int grn_sca = ((spix2 & g_mask) >> 3) * ifactor2;
|
||||||
|
int blu_sca = ((spix2 & b_mask) << 3) * ifactor2;
|
||||||
|
|
||||||
|
int red_blend, grn_blend, blu_blend;
|
||||||
|
if (blendmode == BITMAPTOOLS_BLENDMODE_SCREEN) {
|
||||||
|
// Perform a screen blend Sca + Dca - Sca × Dca
|
||||||
|
red_blend = red_sca + red_dca - (red_sca * red_dca / 65536);
|
||||||
|
grn_blend = grn_sca + grn_dca - (grn_sca * grn_dca / 65536);
|
||||||
|
blu_blend = blu_sca + blu_dca - (blu_sca * blu_dca / 65536);
|
||||||
|
} else {
|
||||||
|
// Perform a normal (src-over) blend
|
||||||
|
red_blend = red_sca + red_dca * (256 - ifactor2) / 256;
|
||||||
|
grn_blend = grn_sca + grn_dca * (256 - ifactor2) / 256;
|
||||||
|
blu_blend = blu_sca + blu_dca * (256 - ifactor2) / 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Divide by the alpha factor
|
||||||
|
int r = ((red_blend / ifactor_blend) << 8) & r_mask;
|
||||||
|
int g = ((grn_blend / ifactor_blend) << 3) & g_mask;
|
||||||
|
int b = ((blu_blend / ifactor_blend) >> 3) & b_mask;
|
||||||
|
|
||||||
|
// Clamp to the appropriate range
|
||||||
|
r = MIN(r_mask, MAX(0, r)) & r_mask;
|
||||||
|
g = MIN(g_mask, MAX(0, g)) & g_mask;
|
||||||
|
b = MIN(b_mask, MAX(0, b)) & b_mask;
|
||||||
|
|
||||||
|
pixel = r | g | b;
|
||||||
|
|
||||||
|
if (swap) {
|
||||||
|
pixel = __builtin_bswap16(pixel);
|
||||||
|
}
|
||||||
|
} else if (blend_source1) {
|
||||||
|
// Apply iFactor1 to source1 only
|
||||||
|
int r = (spix1 & r_mask) * ifactor1 / 256;
|
||||||
|
int g = (spix1 & g_mask) * ifactor1 / 256;
|
||||||
|
int b = (spix1 & b_mask) * ifactor1 / 256;
|
||||||
|
pixel = r | g | b;
|
||||||
|
} else if (blend_source2) {
|
||||||
|
// Apply iFactor2 to source1 only
|
||||||
|
int r = (spix2 & r_mask) * ifactor2 / 256;
|
||||||
|
int g = (spix2 & g_mask) * ifactor2 / 256;
|
||||||
|
int b = (spix2 & b_mask) * ifactor2 / 256;
|
||||||
|
pixel = r | g | b;
|
||||||
|
} else {
|
||||||
|
// Use the destination value
|
||||||
|
pixel = *dptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
*dptr++ = pixel;
|
*dptr++ = pixel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue