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
fix(draw): fix the invalidation of scaled areas #5548
Conversation
cc @lhdjply |
Oh, thank you! I'm on it. |
75e9876
to
0d2dd05
Compare
Huh, it seems working. To be honest I'm not so happy with it because it's hacky here and there. The current image transformation algorithm has some precision issues due to the integer math. I have some ideas to improve it, but it will require much more time. |
I think we can merge first to fix the bug, and then slowly step by step, optimize the code, through the accuracy. |
I tested it. It doesn't seem to fix it. It's still the original result. Original pictureCodeLV_IMG_DECLARE(img_test);
void img_scale_test(void)
{
lv_obj_t *logo1;
logo1 = lv_image_create(lv_screen_active());
lv_image_set_src(logo1, &img_test);
lv_obj_align(logo1,LV_ALIGN_CENTER,-200,0);
lv_image_set_scale(logo1, 256);
lv_obj_t *logo2;
logo2 = lv_image_create(lv_screen_active());
lv_image_set_src(logo2, &img_test);
lv_obj_align(logo2,LV_ALIGN_CENTER,200,0);
lv_image_set_scale(logo2, 255);
} Result |
@IAMMX
Probably it can be improved, but it would be larger scale update. As a workaround you can do 2 things:
|
This method can work, but every time you create the image, be careful to leave some transparent areas.
This method will not work if it is used for picture scaling animations. |
It doesn't change anything, but I meant Unfortunately I don't have a good solution for the accuracy issue now. 🙁 |
In 4dcd66e, the image layer_transform_2.png is added, but in the code, no |
True, thank you. Removed. |
@PGNetHun could you review this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor naming related comments.
I've not tested changes, but see that reference images are updated, so I assume code is OK.
Bonus test case (optional):
Can you please add also 1 test:
show a frame of a sprite/texture atlas, and rotate it.
I use sprites in my app (using lv_image
offset_x
, offset_y
, and rotation), and the sprite is shown wrong (cut of image is after rotation, so parts of next frame appear, too).
Example:
animation of ants: use a sprite PNG as source for lv_img
and lv_animation
(+ callback to set image offset_y
) for frame animation, and rotate the lv_img
to the walking direction.
Well, I haven't realized it so far, but there is no such a feature in LVGL now. Always the whole image is rotated and the clip area of the destination area is just a normal (not rotated) rectangle described by 2 points. To support what you have described we needed to apply a clip area on the source image too. It's possible but not supported now. As workaround you can transform the image as a layer: lv_obj_set_style_transform_rotation(img1, 450, 0);
lv_obj_set_style_transform_pivot_x(img1, 0, 0);
lv_obj_set_style_transform_pivot_y(img1, 0, 0); It's slower and uses more memory, but for small images it shouldn't be a big issue. |
Why did you delete all these test pictures? I think that's the reason #5664 |
I have realized this "issue" only after migrating from v8.3 to v9. |
3c8d615
to
b48eded
Compare
Thank you for pointing it out. I've just added back the reference images images. |
I have reverted it. We will squash commits so don't be scared off the long history 🙂 |
This branch has conflicts that must be resolved |
This reverts commit aeb60a9.
09c361c
to
b41ea93
Compare
Fixed |
Thank you, Neo. All fixed. |
Description of the feature or fix
fix #5447
Notes
lv_conf_template.h
run lv_conf_internal_gen.py and update Kconfig.scripts/code-format.py
(astyle needs to be installed) and follow the Code Conventions