diff --git a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp index 02d6ac16f..2342b04e3 100644 --- a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp +++ b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp @@ -23,6 +23,7 @@ #include #include #include +#include namespace ImGuiExt { @@ -222,14 +223,20 @@ namespace ImGuiExt { } Texture Texture::fromSVG(const char *path, int width, int height, Filter filter) { + #if defined(OS_MACOS) + const auto scaleFactor = getBackingScaleFactor(); + #else + const auto scaleFactor = 1.0F; + #endif + auto document = lunasvg::Document::loadFromFile(path); - auto bitmap = document->renderToBitmap(width, height); + auto bitmap = document->renderToBitmap(width * scaleFactor, height * scaleFactor); auto texture = createMultisampleTextureFromRGBA8Array(bitmap.data(), bitmap.width(), bitmap.height(), filter); Texture result; - result.m_width = bitmap.width(); - result.m_height = bitmap.height(); + result.m_width = bitmap.width() / scaleFactor; + result.m_height = bitmap.height() / scaleFactor; result.m_textureId = texture; return result; @@ -240,15 +247,21 @@ namespace ImGuiExt { } Texture Texture::fromSVG(std::span buffer, int width, int height, Filter filter) { + #if defined(OS_MACOS) + const auto scaleFactor = getBackingScaleFactor(); + #else + const auto scaleFactor = 1.0F; + #endif + auto document = lunasvg::Document::loadFromData(reinterpret_cast(buffer.data()), buffer.size()); - auto bitmap = document->renderToBitmap(width, height); + auto bitmap = document->renderToBitmap(width * scaleFactor, height * scaleFactor); bitmap.convertToRGBA(); auto texture = createMultisampleTextureFromRGBA8Array(bitmap.data(), bitmap.width(), bitmap.height(), filter); Texture result; - result.m_width = bitmap.width(); - result.m_height = bitmap.height(); + result.m_width = bitmap.width() / scaleFactor; + result.m_height = bitmap.height() / scaleFactor; result.m_textureId = texture; return result;