mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 04:59:01 +08:00
Follow-up b4c6ec10 : Improved creation ScalableBitmap from .jpg and .png
This commit is contained in:
parent
23e5000904
commit
95bb0b4748
@ -855,15 +855,26 @@ ScalableBitmap::ScalableBitmap(wxWindow* parent, boost::filesystem::path& icon_p
|
|||||||
wxString path = Slic3r::GUI::from_u8(icon_path.string());
|
wxString path = Slic3r::GUI::from_u8(icon_path.string());
|
||||||
wxBitmap bitmap;
|
wxBitmap bitmap;
|
||||||
const std::string ext = icon_path.extension().string();
|
const std::string ext = icon_path.extension().string();
|
||||||
if (ext == ".png") {
|
|
||||||
bitmap.LoadFile(path, wxBITMAP_TYPE_PNG);
|
if (ext == ".png" || ext == ".jpg") {
|
||||||
wxBitmap::Rescale(bitmap, icon_size);
|
bitmap.LoadFile(path, ext == ".png" ? wxBITMAP_TYPE_PNG : wxBITMAP_TYPE_JPEG);
|
||||||
m_bmp = wxBitmapBundle(bitmap);
|
|
||||||
}
|
std::set<double> scales = { 1.0 };
|
||||||
else if (ext == ".jpg") {
|
#ifdef __APPLE__
|
||||||
bitmap.LoadFile(path, wxBITMAP_TYPE_JPEG);
|
scales.emplace(Slic3r::GUI::mac_max_scaling_factor());
|
||||||
wxBitmap::Rescale(bitmap, icon_size);
|
#elif _WIN32
|
||||||
m_bmp = wxBitmapBundle(bitmap);
|
size_t disp_cnt = wxDisplay::GetCount();
|
||||||
|
for (size_t disp = 0; disp < disp_cnt; ++disp)
|
||||||
|
scales.emplace(wxDisplay(disp).GetScaleFactor());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxVector<wxBitmap> bmps;
|
||||||
|
for (double scale : scales) {
|
||||||
|
wxBitmap bmp = bitmap;
|
||||||
|
wxBitmap::Rescale(bmp, icon_size * scale);
|
||||||
|
bmps.push_back(bmp);
|
||||||
|
}
|
||||||
|
m_bmp = wxBitmapBundle::FromBitmaps(bmps);
|
||||||
}
|
}
|
||||||
else if (ext == ".svg") {
|
else if (ext == ".svg") {
|
||||||
m_bmp = wxBitmapBundle::FromSVGFile(path, icon_size);
|
m_bmp = wxBitmapBundle::FromSVGFile(path, icon_size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user