Ok according your suggestion I changed to :
if(bSnapshot) {
uint32_t data = lv_color_to32(*color_p);
fsSnapFile.write((const uint8_t *)(&data), sizeof(uint32_t));
}
but :
C:\ImageMagick\ImageMagick-7.0.8-Q16>magick.exe -size 480x320 -depth 8 rgba:snapshot.bin snap.bmp
give me
so I changed the order in command line:
C:\ImageMagick\ImageMagick-7.0.8-Q16>magick.exe -size 480x320 -depth 8 bgra:snapshot.bin snap.bmp
and now I get back the correct colors
So to sum up the global solution :
//Global variables
static File fsSnapFile;
static bool bSnapshot;
//Snap function
bool snapshot()
{
fsSnapFile = SPIFFS.open("/snapshot.bin", "w");
if (!fsSnapFile) {
return false;
}
bSnapshot = true;
lv_obj_invalidate(lv_scr_act());
lv_refr_now(lv_disp_get_default()); /* Will call our disp_drv.disp_flush function */
bSnapshot = false;
fsSnapFile.close();
return true;
}
/* Display flushing procedure*/
void esp_lv_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
uint16_t c;
tft_screen.startWrite(); /* Start new TFT transaction */
tft_screen.setAddrWindow(area->x1, area->y1, (area->x2 - area->x1 + 1), (area->y2 - area->y1 + 1)); /* set the working window */
for (int y = area->y1; y <= area->y2; y++) {
for (int x = area->x1; x <= area->x2; x++) {
c = color_p->full;
tft_screen.writeColor(c, 1);
if(bSnapshot) {
uint32_t data = lv_color_to32(*color_p);
fsSnapFile.write((const uint8_t *)(&data), sizeof(uint32_t));
}
color_p++;
}
}
tft.endWrite(); /* terminate TFT transaction */
lv_disp_flush_ready(disp); /* tell lvgl that flushing is done */
}
then for conversion (magick.exe is the Windows equivalent in ImageMagick for convert due to some name conflict)
C:\ImageMagick\ImageMagick-7.0.8-Q16>magick.exe -size 480x320 -depth 8 bgra:snapshot.bin snap.bmp
Thank you for your advices