From a6e8030724bd9bd7104fd04b86ea0902e0d8c380 Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Mon, 30 Oct 2023 18:31:01 -0700 Subject: [PATCH] modules: Add image file loading to screen drawing methods. --- src/omv/modules/py_display.c | 4 ++-- src/omv/modules/py_image.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/omv/modules/py_display.c b/src/omv/modules/py_display.c index 834d2ed6d..e38476dc0 100644 --- a/src/omv/modules/py_display.c +++ b/src/omv/modules/py_display.c @@ -145,7 +145,8 @@ STATIC mp_obj_t py_display_write(uint n_args, const mp_obj_t *pos_args, mp_map_t mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - image_t *image = py_helper_arg_to_image(args[ARG_image].u_obj, 0); + fb_alloc_mark(); + image_t *image = py_helper_arg_to_image(args[ARG_image].u_obj, ARG_IMAGE_ANY | ARG_IMAGE_ALLOC); rectangle_t roi = py_helper_arg_to_roi(args[ARG_roi].u_obj, image); if (args[ARG_channel].u_int < -1 || args[ARG_channel].u_int > 2) { @@ -167,7 +168,6 @@ STATIC mp_obj_t py_display_write(uint n_args, const mp_obj_t *pos_args, mp_map_t const uint16_t *color_palette = py_helper_arg_to_palette(args[ARG_color_palette].u_obj, PIXFORMAT_RGB565); const uint8_t *alpha_palette = py_helper_arg_to_palette(args[ARG_alpha_palette].u_obj, PIXFORMAT_GRAYSCALE); - fb_alloc_mark(); py_display_p_t *display_p = (py_display_p_t *) MP_OBJ_TYPE_GET_SLOT(self->base.type, protocol); display_p->write(self, image, args[ARG_x].u_int, args[ARG_y].u_int, x_scale, y_scale, &roi, args[ARG_channel].u_int, args[ARG_alpha].u_int, color_palette, alpha_palette, args[ARG_hint].u_int); diff --git a/src/omv/modules/py_image.c b/src/omv/modules/py_image.c index e78db0120..ebd071f3c 100644 --- a/src/omv/modules/py_image.c +++ b/src/omv/modules/py_image.c @@ -1555,8 +1555,9 @@ STATIC mp_obj_t py_image_draw_edges(uint n_args, const mp_obj_t *args, mp_map_t STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_draw_edges_obj, 2, py_image_draw_edges); STATIC mp_obj_t py_image_draw_image(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { + fb_alloc_mark(); image_t *arg_img = py_helper_arg_to_image(args[0], ARG_IMAGE_MUTABLE); - image_t *arg_other = py_helper_arg_to_image(args[1], ARG_IMAGE_UNCOMPRESSED); + image_t *arg_other = py_helper_arg_to_image(args[1], ARG_IMAGE_ANY | ARG_IMAGE_ALLOC); const mp_obj_t *arg_vec; uint offset = py_helper_consume_array(n_args, args, 2, 2, &arg_vec); @@ -1634,7 +1635,6 @@ STATIC mp_obj_t py_image_draw_image(uint n_args, const mp_obj_t *args, mp_map_t arg_y_scale = arg_x_scale; } - fb_alloc_mark(); imlib_draw_image(arg_img, arg_other, arg_x_off, arg_y_off, arg_x_scale, arg_y_scale, &arg_roi, arg_rgb_channel, arg_alpha, color_palette, alpha_palette, hint, NULL, NULL, NULL); fb_alloc_free_till_mark();