From b46ba7955782ff08c9784d581a7a6af499a43e5b Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Mon, 16 Nov 2020 00:47:07 +0200 Subject: [PATCH] Update JPEG frame buffer after loading/creating images. * With this fix the frame buffer will be updated instantly after loading or creating new images with the copy_to_fb flag set to true. * There's no need to flush the framebuffer after loading or creating images anymore, however the sensor (or image) flush() still needs to be called after drawing to see the updates. --- scripts/examples/03-Drawing/copy2fb.py | 10 ++-------- src/omv/py/py_image.c | 8 ++++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/scripts/examples/03-Drawing/copy2fb.py b/scripts/examples/03-Drawing/copy2fb.py index 42c46edcf..5cd34710f 100644 --- a/scripts/examples/03-Drawing/copy2fb.py +++ b/scripts/examples/03-Drawing/copy2fb.py @@ -17,11 +17,5 @@ sensor.set_pixformat(sensor.GRAYSCALE) # Load image img = image.Image("/example.bmp", copy_to_fb=True) -# Add drawing code here. -# img.draw_line(...) - -# Flush FB -sensor.flush() - -# Add a small delay to allow the IDE to read the flushed image. -time.sleep(100) +# Add a small delay to allow the IDE to read the loaded image. +time.sleep(500) diff --git a/src/omv/py/py_image.c b/src/omv/py/py_image.c index bb4bdc810..503177a10 100644 --- a/src/omv/py/py_image.c +++ b/src/omv/py/py_image.c @@ -7128,10 +7128,6 @@ mp_obj_t py_image_load_image(uint n_args, const mp_obj_t *args, mp_map_t *kw_arg } } - if (copy_to_fb) { - fb_update_jpeg_buffer(); - } - image_t image = {0}; if (mode) { @@ -7190,6 +7186,10 @@ mp_obj_t py_image_load_image(uint n_args, const mp_obj_t *args, mp_map_t *kw_arg arg_other->bpp = image.bpp; } + if (copy_to_fb) { + fb_update_jpeg_buffer(); + } + return py_image_from_struct(&image); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_load_image_obj, 1, py_image_load_image);