Create an image file with screenshots

Is it possible to create an image file containing the screenshot of the page in use?
Do you have any examples to recommend?


I think you can make flag f.e. bool needScreenShot = false; and if it flag set - copy disp_drv.buffer in disp_drv.flush_cb() function to screenshot buffer. Then save this buffer to … file?

Screenshots are not supported natively right now, but an approach similar to what was described by @spider_vc should work.

  • Have a screenshot flag in your driver and set it to true.
  • Call lv_obj_invalidate(lv_scr_act()) to force the entire screen to be redrawn.
  • As you receive portions of the display in your flush_cb callback, store them to the correct locations in a buffer.
  • When drawing finishes (you can detect this with monitor_cb) save the finished buffer as an image. BMP is probably the easiest but this is largely up to you.

There is no built-in solution in LVGL to do this as many platforms don’t have enough RAM to store the finished screenshot in one piece. They thus need to save the portions to a file gradually, or send it to a host computer for further processing where there is more RAM available.

Look like I describe same method :crazy_face:

What resources do you have on your board, SD card? Sufficient RAM to hold an entire screen? Any serial or USB link to a computer?

The solution will depend on what you have but as mentioned, the trick is to force a full rendering and then capture the rendering request(s).

If your configuration is no SD, insufficient RAM and some serial/USB link to a computer, I can point you to what I did.