I have very little time right now so I’m not able to contribute much, but I found this on Github it appears to be under an MIT license so you maybe able to use this code?
Despite the filename if you look down near the bottom of the file you will find there is an integer implementation which would be compatible with LVGL I believe…
@pete-pjb After a day of trying, I made some progress. Currently I understand the idea and implementation of Fast Gaussian Blur. But here is to blur the picture. I saw its specific implementation. In fact, it is to take out some data in the picture and perform blur processing.
So how do I take out the data of obj in lvgl and then perform blur processing?
I am sorry for my late reply, I really am a little overloaded with work right now. I apologise for not knowing about this previously but I have just seen something in the LVGL documentation which I wasn’t aware of but may potentially be a good way forward for you.
I would take a look at the canvas object in the documentation:
On a quick scan it looks like it might be possible to put your background image on a canvas, then use the canvas_blur_xxx() functions on an area of the image and then place your rectangle over the canvas and make it transparent to achieve something close to your goal.
If these functions are not suitable you could perhaps think about adding an API along the lines of canvas_blur_gaus() or canvas_blur_ver_hor() in the same template as the current canvas_blur_xxx() functions using the code in the link from my previous post maybe?
It might be worth a bit of experimentation. It looks like @kisvegabor(I see he asked you to move this request from Github) may be making a comment at some point also he will obviously have a much better idea of how best to implement your ideas.
Hi @pete-pjb Thank you for taking the time out of your busy schedule to reply to me!
I know the canvas in lvgl before,but I’m not sure if it can achieve the effect of background-filter:blur in CSS.
I’ve got some ideas on your previous suggestion and I’m trying to implement them.
My idea is this: get the image elements after obj in lvgl and perform fast Gaussian filtering.
However, I’m not quite sure how to get the image element behind each obj, I’m still thinking about this.
From the example you gave, I also found that Gaussian filtering of a picture is actually taking out the data behind the picture, performing fast Gaussian filtering calculations, and then combining the data into a new picture. So I think this method should also work for obj in lvgl
Stupid suggestion, but do you have any moving parts on the screen or dynamic background images? If not, then as an alternative and for more efficiency I’d add the blur to the background image (like literally bake it into the image with Gimp/Photoshop) and make the buttons transparent (except for the borders).
hi, @pete-pjb I used the canvas function of lvgl to make an approximate effect, such as the picture on my right, but the blurring effect of the upper and lower areas still looks poor, why is this?
The picture you see, the left is the effect achieved by Gaussian blur, the entire blur effect looks uniform, but the right is the blur of LVGL, the upper and lower areas in the red box look a bit transparent, and the blur in the middle area looks Not even enough
I will take a quick look to see if I can do anything to help. If I can do something fairly quickly I will post a link to a fork of the LVGL repository back here.
I started to work on an automatic “widget snapshot” feature. With this any widgets (with all its children) can be “snapshot-ed”. Once it’s an image you can do any image transformations on them, e.g. zoom or rotation. It’s still in an early stage but somehow maybe it can help to achieve the blurring effect as well.
Note that lv_snapshot already exists in LVGL and even it (maybe with some modifications) can help.
E.g. if lv_snapshot could take a snapshot about a region of the widget it could be blurred manually and that image could be used as a parent of other widgets.
An other option could be this:
Set disp_drv->full_refresh = 1
Create a transparent container where you need the blur
In the LV_EVENT_DRAW_MAIN event of that container get the current draw buffer and blur it where required.
I looked into the internal implementations of lv_canvas_blur_hor and lv_canvas_blur_ver, they seem to be just simple box filtering, so the blurring effect is not ideal. Can I add a lv_canvas_blur_xxxx function to expect a Gaussian blur effect?
For example is the method of fast Gaussian blur in this link used here?
@kisvegabor
I looked into the internal implementations of lv_canvas_blur_hor and lv_canvas_blur_ver, they seem to be just simple box filtering, so the blurring effect is not ideal. Can I add a lv_canvas_blur_xxxx function to expect a Gaussian blur effect?
For example is the method of fast Gaussian blur in this link used here?
@kisvegabor when i run lv_canvas_blur_hor and lv_canvas_blur_ver 3 times,It does not achieve the effect of Gaussian blur,
The picture you see, the left is the effect achieved by Gaussian blur, the entire blur effect looks uniform, but the right is the blur of LVGL, the upper and lower areas in the red box look a bit transparent, and the blur in the middle area looks Not even enough