Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object Rotation for Binary Images #6193

Open
fatihozen3 opened this issue May 7, 2024 · 5 comments
Open

Object Rotation for Binary Images #6193

fatihozen3 opened this issue May 7, 2024 · 5 comments

Comments

@fatihozen3
Copy link

Introduce the problem

I use IMXRT1170 MCU and LVGL v9.1.0. I have a simple problem but I don't know the reason. I want to see my image rotated with lv_img_set_angle function but I face with MemManage_Handler. What could be the reason ?

        img_test_1 = lv_img_create(screen_test);
        lv_obj_add_flag(img_test_1, LV_OBJ_FLAG_CLICKABLE);
        lv_img_set_src(img_test_1, "F:/sample.bin");
        lv_img_set_pivot(img_test_1, 50, 50);
        lv_img_set_angle(img_test_1, 100);
        lv_obj_set_pos(img_test_1, 100, 100);
        lv_obj_set_size(img_test_1, 64, 69);

image

Proposal

No response

@liamHowatt
Copy link
Collaborator

Hi, what version are you using (v8, v9, etc.)?

When I try your to rotate a binary image it doesn't appear correctly, so that's definitely a concern.

However I do not get a memory error. I think an error is being encountered and the program proceeds with a NULL or otherwise invalid value. Could you please enable LV_LOG_LEVEL_WARN and LV_USE_ASSERT_NULL, LV_USE_ASSERT_MALLOC if not already enabled?

Also, does it work with the binary image when it's not rotated?

@fatihozen3
Copy link
Author

Hi, what version are you using (v8, v9, etc.)?

When I try your to rotate a binary image it doesn't appear correctly, so that's definitely a concern.

However I do not get a memory error. I think an error is being encountered and the program proceeds with a NULL or otherwise invalid value. Could you please enable LV_LOG_LEVEL_WARN and LV_USE_ASSERT_NULL, LV_USE_ASSERT_MALLOC if not already enabled?

Also, does it work with the binary image when it's not rotated?

Hi, I use v9.1.0, I can see binary images when it is not rotated, but I have not tried unbinary pictures. All things are enabled as you suggested

@fatihozen3
Copy link
Author

fatihozen3 commented May 9, 2024

I have added it as c array not binary and it is rotated with lv_img_set_angle function successfully. But when I try it with binary image, no image is shown on the screen.

Second issue is angle value. For one picture when I write there 434, I see MemManageHandler fault, but when I write 435, I don't see this fault, screen can load but image doesn't shown in screen. I also tried it negative values same result as positive ones.

I have tried these 434,435 values for different image, it does not work. For both value I see MemManageHandler so it is related with picture(some of it's parameters maybe width height). But for sure I could not see rotated binary image on the screen.

@fatihozen3
Copy link
Author

fatihozen3 commented May 9, 2024

I use ARGB8888 color format. There is written sth useful here
The transformations require the whole image to be available. Therefore indexed images (LV_COLOR_FORMAT_I1/2/4/8_...), alpha only images cannot be transformed. In other words transformations work only on normal (A)RGB or A8 images stored as C array, or if a custom Image decoder returns the whole image.

I need to find a way to rotate binary file :/ I have to use them as binary format for update strategy...

@fatihozen3 fatihozen3 changed the title Object Rotation Object Rotation for Binary Images May 10, 2024
@liamHowatt
Copy link
Collaborator

liamHowatt commented May 10, 2024

Ah, so it's not supported for now. Good find. I think some undefined behavior is reasonable when you try to transform it, then. I could not reproduce the lv_img_set_angle(img_test_1, 434) crash but it's not worth fixing until it's supposed to be supported.

The situation right now is a bit weird.

bin decoder png decoder
decodes whole image 👎️ ✅️
transform works 👎️ ✅️
transform works if whole image was cached 👎️ N/A

The bin decoder decoding incrementally is supposed to be helpful, but it actually punishes users who want to transform the image. Even if the image cache is big enough to cache the whole image after the first decode, it still can't be transformed even though the whole image is now available.

I think something could be done about this. Maybe a flag for the image decoder that tells it to decode the whole image immediately.

For your requirement of needing to load an image dynamically, there are a few options! 🙂 The simplest is to just store the image on your storage device as PNG! I'd recommend enabling image caching (LV_CACHE_DEF_SIZE and LV_IMAGE_HEADER_CACHE_DEF_CNT in lv_conf.h) so it doesn't read the file every time. (nevermind, it persists if the image object isn't deleted) Another option is to store the raw image data from the C array in a binary file, and then lv_fs_read it and initialize the fields of an lv_image_dsc_t manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants