diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index fe4d57fcec..1582fe35aa 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -1636,7 +1636,7 @@ static const ImWchar ranges_keyboard_shortcuts[] = #endif // __APPLE__ -std::vector ImGuiWrapper::load_svg(const std::string& bitmap_name, unsigned target_width, unsigned target_height) +std::vector ImGuiWrapper::load_svg(const std::string& bitmap_name, unsigned target_width, unsigned target_height, unsigned *outwidth, unsigned *outheight) { std::vector empty_vector; @@ -1667,6 +1667,9 @@ std::vector ImGuiWrapper::load_svg(const std::string& bitmap_name ::nsvgDeleteRasterizer(rast); ::nsvgDelete(image); + *outwidth = width; + *outheight = height; + return data; } @@ -1951,11 +1954,12 @@ void ImGuiWrapper::init_font(bool compress) if (const ImFontAtlas::CustomRect* rect = io.Fonts->GetCustomRectByIndex(rect_id)) { assert(rect->Width == icon_sz); assert(rect->Height == icon_sz); - std::vector raw_data = load_svg(icon.second, icon_sz, icon_sz); + unsigned outwidth, outheight; + std::vector raw_data = load_svg(icon.second, icon_sz, icon_sz, &outwidth, &outheight); const ImU32* pIn = (ImU32*)raw_data.data(); - for (int y = 0; y < icon_sz; y++) { + for (unsigned y = 0; y < outheight; y++) { ImU32* pOut = (ImU32*)pixels + (rect->Y + y) * width + (rect->X); - for (int x = 0; x < icon_sz; x++) + for (unsigned x = 0; x < outwidth; x++) *pOut++ = *pIn++; } } @@ -1967,11 +1971,12 @@ void ImGuiWrapper::init_font(bool compress) if (const ImFontAtlas::CustomRect* rect = io.Fonts->GetCustomRectByIndex(rect_id)) { assert(rect->Width == icon_sz); assert(rect->Height == icon_sz); - std::vector raw_data = load_svg(icon.second, icon_sz, icon_sz); + unsigned outwidth, outheight; + std::vector raw_data = load_svg(icon.second, icon_sz, icon_sz, &outwidth, &outheight); const ImU32* pIn = (ImU32*)raw_data.data(); - for (int y = 0; y < icon_sz; y++) { + for (unsigned y = 0; y < outheight; y++) { ImU32* pOut = (ImU32*)pixels + (rect->Y + y) * width + (rect->X); - for (int x = 0; x < icon_sz; x++) + for (unsigned x = 0; x < outwidth; x++) *pOut++ = *pIn++; } } @@ -1983,11 +1988,12 @@ void ImGuiWrapper::init_font(bool compress) if (const ImFontAtlas::CustomRect* rect = io.Fonts->GetCustomRectByIndex(rect_id)) { assert(rect->Width == icon_sz); assert(rect->Height == icon_sz); - std::vector raw_data = load_svg(icon.second, icon_sz, icon_sz); + unsigned outwidth, outheight; + std::vector raw_data = load_svg(icon.second, icon_sz, icon_sz, &outwidth, &outheight); const ImU32* pIn = (ImU32*)raw_data.data(); - for (int y = 0; y < icon_sz; y++) { + for (unsigned y = 0; y < outheight; y++) { ImU32* pOut = (ImU32*)pixels + (rect->Y + y) * width + (rect->X); - for (int x = 0; x < icon_sz; x++) + for (unsigned x = 0; x < outwidth; x++) *pOut++ = *pIn++; } } diff --git a/src/slic3r/GUI/ImGuiWrapper.hpp b/src/slic3r/GUI/ImGuiWrapper.hpp index 6b584a60c0..5280b876bf 100644 --- a/src/slic3r/GUI/ImGuiWrapper.hpp +++ b/src/slic3r/GUI/ImGuiWrapper.hpp @@ -223,7 +223,7 @@ private: void render_draw_data(ImDrawData *draw_data); bool display_initialized() const; void destroy_font(); - std::vector load_svg(const std::string& bitmap_name, unsigned target_width, unsigned target_height); + std::vector load_svg(const std::string& bitmap_name, unsigned target_width, unsigned target_height, unsigned *outwidth, unsigned *outheight); static const char* clipboard_get(void* user_data); static void clipboard_set(void* user_data, const char* text);