How to take a snapshot and save it on SD card

Description

Hi everyone.

I would like to take a screenshot and save it on an SD card to finally use it on my PC.
I don’t want to use PC simulator to take screenshot because I want to take them on the “in situ” system.

What MCU/Processor/Board and compiler are you using?

Espressif ESP32-WROOM-32 on a custom board
ESP-IDF v4.4 (8153bfe4125e6a608abccf1561fd10285016c90a)

What LVGL version are you using?

LVGL v8.2 (0b5a1d4b23975b920ff841ea9cd038802f51711b)

What do you want to achieve?

I want to take a screenshot, save it on an SD card and then (convert it) and use it on my PC as a .bmp picture.

What have you tried so far?

I’ve tried to reproduce this : Take snapshots of current screen | LVGL’s Blog
It works well but I only managed to capture the background of my screen, I didn’t succeed to capture the whole screen (background + all objects on it like labels, buttons…).

So I tried to use the new snapshot tool in LVGL Snapshot — LVGL documentation as it was described on this topic How do I save my interface as a picture?
But the problem is that I need 230 kB to store the entire screen (320 x 240 TFT screen, 16 bits colors) and lv_mem_alloc can’t provide more than 128 kB.

Code to reproduce

ESP_LOGI(TAG, "Memory needed : %d", lv_snapshot_buf_size_needed(lv_scr_act(), LV_IMG_CF_TRUE_COLOR_ALPHA));
snapshot = lv_snapshot_take(lv_scr_act(), LV_IMG_CF_TRUE_COLOR_ALPHA);
if(snapshot == NULL){
    ESP_LOGE(TAG, "Failed to take snapshot");
    return ESP_FAIL;
} 

This code returns ESP_FAIL because lv_snapshot_take() can’t take so much memory.

How shoud I resolve that ?

Thanks.

Any ideas?