FIX: load_from_svg_file_change_color() supports 8bit colour values

JIRA: nojira
Change-Id: I72e68bd9cb547064736d130205074da0e7eabd60
This commit is contained in:
Mack 2024-07-31 16:18:09 +08:00 committed by lane.wei
parent 02a38db9c4
commit 8bdac292a0
2 changed files with 5 additions and 3 deletions

View File

@ -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) {

View File

@ -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);
{