From f388190787a742c7301d5d4e23975e5756c8b562 Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Wed, 16 Oct 2024 11:34:22 +0200 Subject: [PATCH] Add FinalAppWindowScreenshotFramebufferScale --- src/hello_imgui/hello_imgui_screenshot.h | 1 + src/hello_imgui/impl/hello_imgui_screenshot.cpp | 10 ++++++++++ .../internal/backend_impls/abstract_runner.cpp | 3 +++ 3 files changed, 14 insertions(+) diff --git a/src/hello_imgui/hello_imgui_screenshot.h b/src/hello_imgui/hello_imgui_screenshot.h index d7450605..0ce4fd28 100644 --- a/src/hello_imgui/hello_imgui_screenshot.h +++ b/src/hello_imgui/hello_imgui_screenshot.h @@ -25,4 +25,5 @@ namespace HelloImGui ImageBuffer AppWindowScreenshotRgbBuffer(); ImageBuffer FinalAppWindowScreenshotRgbBuffer(); + float FinalAppWindowScreenshotFramebufferScale(); } diff --git a/src/hello_imgui/impl/hello_imgui_screenshot.cpp b/src/hello_imgui/impl/hello_imgui_screenshot.cpp index 48cffde0..93d2fe98 100644 --- a/src/hello_imgui/impl/hello_imgui_screenshot.cpp +++ b/src/hello_imgui/impl/hello_imgui_screenshot.cpp @@ -13,15 +13,25 @@ namespace HelloImGui } ImageBuffer gFinalAppWindowScreenshotRgbBuffer; + float gFinalAppWindowScreenshotFramebufferScale = 1.0f; void setFinalAppWindowScreenshotRgbBuffer(const ImageBuffer& b) { gFinalAppWindowScreenshotRgbBuffer = b; } + void setFinalAppWindowScreenshotFramebufferScale(float scale) + { + gFinalAppWindowScreenshotFramebufferScale = scale; + } ImageBuffer FinalAppWindowScreenshotRgbBuffer() { return gFinalAppWindowScreenshotRgbBuffer; } + float FinalAppWindowScreenshotFramebufferScale() + { + return gFinalAppWindowScreenshotFramebufferScale; + } + } diff --git a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp index 335769d7..b08085dc 100644 --- a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp +++ b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp @@ -78,6 +78,7 @@ namespace HelloImGui { // Encapsulated inside hello_imgui_screenshot.cpp void setFinalAppWindowScreenshotRgbBuffer(const ImageBuffer& b); +void setFinalAppWindowScreenshotFramebufferScale(float scale); // Encapsulated inside hello_imgui_font.cpp bool _reloadAllDpiResponsiveFonts(); @@ -1436,6 +1437,8 @@ void AbstractRunner::TearDown(bool gotException) { ImageBuffer b = ScreenshotRgb(); setFinalAppWindowScreenshotRgbBuffer(b); + float scale = (ImGui::GetIO().DisplayFramebufferScale.x + ImGui::GetIO().DisplayFramebufferScale.y) / 2.f; + setFinalAppWindowScreenshotFramebufferScale(scale); } if (params.appWindowParams.restorePreviousGeometry) HelloImGuiIniSettings::SaveLastRunWindowBounds(IniSettingsLocation(params),