From 8bdac292a0bd34786189f4ca320f646340157d2c Mon Sep 17 00:00:00 2001 From: Mack Date: Wed, 31 Jul 2024 16:18:09 +0800 Subject: [PATCH] FIX: load_from_svg_file_change_color() supports 8bit colour values JIRA: nojira Change-Id: I72e68bd9cb547064736d130205074da0e7eabd60 --- src/slic3r/GUI/BitmapCache.cpp | 6 ++++-- src/slic3r/GUI/GCodeViewer.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/BitmapCache.cpp b/src/slic3r/GUI/BitmapCache.cpp index 5582ece23..9e6d50fe2 100644 --- a/src/slic3r/GUI/BitmapCache.cpp +++ b/src/slic3r/GUI/BitmapCache.cpp @@ -549,8 +549,10 @@ bool BitmapCache::load_from_svg_file_change_color(const std::string &filename, u if (image == nullptr) { return false; } - - unsigned int change_color = nsvg__parseColorHex(hexColor); + char temp_color[8]; + strncpy(temp_color, hexColor, 7); + temp_color[7] = '\0'; + unsigned int change_color = nsvg__parseColorHex(temp_color); change_color |= (unsigned int) (1.0f * 255) << 24; // opacity unsigned int green_color = 4282560000; for (NSVGshape* shape = image->shapes; shape != nullptr; shape = shape->next) { diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 7076fe701..22a349d8d 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -4629,7 +4629,7 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding) float line_height = ImGui::GetFrameHeight(); int AMS_filament_max_num = std::max(m_left_extruder_filament.size(), m_right_extruder_filament.size()); float three_words_width = imgui.calc_text_size("ABC").x; - float AMS_container_height = (std::ceil(AMS_filament_max_num / 4.0f) * (three_words_width * 1.5f + line_height) + (line_height * 4)); + float AMS_container_height = (std::ceil(AMS_filament_max_num / 4.0f) * (three_words_width * 1.6f + line_height) + (line_height * 5)); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(window_padding * 3, 0)); ImGui::BeginChild("#AMS", ImVec2(0, AMS_container_height), false, ImGuiWindowFlags_AlwaysUseWindowPadding); {