From 460374d6b2b33e142fd3ba83b56c7e007f292a47 Mon Sep 17 00:00:00 2001 From: "liz.li" Date: Mon, 22 Aug 2022 15:51:59 +0800 Subject: [PATCH] ENH:rescale thumbnail_3mf cover Change-Id: I1e0192a66f36898f925adc033457d6f42d3ca999 --- src/slic3r/GUI/Auxiliary.cpp | 5 +++-- src/slic3r/GUI/GUI_Utils.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/Auxiliary.cpp b/src/slic3r/GUI/Auxiliary.cpp index c3ea3d703..8115f1d72 100644 --- a/src/slic3r/GUI/Auxiliary.cpp +++ b/src/slic3r/GUI/Auxiliary.cpp @@ -378,14 +378,15 @@ void AuFile::on_set_cover() } bool result = true; - wxImage thumbnail_img;; + wxImage thumbnail_img; + result = generate_image(m_file_path.string(), thumbnail_img, _3MF_COVER_SIZE); if (result) { auto cover_img_path = dir_path.string() + "/thumbnail_3mf.png"; thumbnail_img.SaveFile(encode_path(cover_img_path.c_str())); } - result = generate_image(m_file_path.string(), thumbnail_img, PRINTER_THUMBNAIL_SMALL_SIZE, GERNERATE_IMAGE_CROP_VERTICAL); + result = generate_image(m_file_path.string(), thumbnail_img, PRINTER_THUMBNAIL_SMALL_SIZE); if (result) { auto small_img_path = dir_path.string() + "/thumbnail_small.png"; thumbnail_img.SaveFile(encode_path(small_img_path.c_str())); diff --git a/src/slic3r/GUI/GUI_Utils.cpp b/src/slic3r/GUI/GUI_Utils.cpp index c2f6600d7..1c472f420 100644 --- a/src/slic3r/GUI/GUI_Utils.cpp +++ b/src/slic3r/GUI/GUI_Utils.cpp @@ -450,7 +450,7 @@ bool generate_image(const std::string &filename, wxImage &image, wxSize img_size if (method == GERNERATE_IMAGE_RESIZE) { float h_factor = img.GetHeight() / (float) image.GetHeight(); float w_factor = img.GetWidth() / (float) image.GetWidth(); - float factor = std::max(h_factor, w_factor); + float factor = std::min(h_factor, w_factor); int tar_height = (int) ((float) img.GetHeight() / factor); int tar_width = (int) ((float) img.GetWidth() / factor); img = img.Rescale(tar_width, tar_height); @@ -465,7 +465,7 @@ bool generate_image(const std::string &filename, wxImage &image, wxSize img_size return false; } - image.ConvertAlphaToMask(image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue()); + //image.ConvertAlphaToMask(image.GetMaskRed(), image.GetMaskGreen(), image.GetMaskBlue()); return true; }