From 2ab459598c60b7df0d4b0dddf4a1e7c71ae985a1 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 17 Jul 2024 17:22:59 +1000 Subject: Encode snapshots as PNGs when saving to disk --- src/tangara/ui/ui_fsm.cpp | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'src/tangara/ui/ui_fsm.cpp') diff --git a/src/tangara/ui/ui_fsm.cpp b/src/tangara/ui/ui_fsm.cpp index 4f93fe61..cd39dc9c 100644 --- a/src/tangara/ui/ui_fsm.cpp +++ b/src/tangara/ui/ui_fsm.cpp @@ -65,6 +65,7 @@ #include "ui/screen.hpp" #include "ui/screen_lua.hpp" #include "ui/screen_splash.hpp" +#include "ui/screenshot.hpp" #include "ui/ui_events.hpp" namespace ui { @@ -371,22 +372,7 @@ void UiState::react(const Screenshot& ev) { if (!sCurrentScreen) { return; } - ESP_LOGI(kTag, "taking snapshot"); - lv_draw_buf_t* buf = - lv_snapshot_take(sCurrentScreen->root(), LV_COLOR_FORMAT_RGB888); - if (!buf) { - ESP_LOGW(kTag, "snapshot failed"); - return; - } - ESP_LOGI(kTag, "writing to file"); - std::string fullpath = "//sdcard/" + ev.filename; - auto res = lv_draw_buf_save_to_file(buf, fullpath.c_str()); - lv_draw_buf_destroy(buf); - if (res == LV_RESULT_OK) { - ESP_LOGI(kTag, "write okay!"); - } else { - ESP_LOGE(kTag, "write failed!"); - } + SaveScreenshot(sCurrentScreen->root(), ev.filename); } void UiState::react(const system_fsm::KeyLockChanged& ev) { -- cgit v1.2.3