mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 13:25:56 +08:00
ScalableBitmap: Check if the bitmap has a square shape,
when loading from the path
This commit is contained in:
parent
3bd0728bc6
commit
86780b5a6c
@ -475,6 +475,18 @@ ScalableBitmap::ScalableBitmap(wxWindow* parent, boost::filesystem::path& icon_p
|
|||||||
if (ext == ".png" || ext == ".jpg") {
|
if (ext == ".png" || ext == ".jpg") {
|
||||||
bitmap.LoadFile(path, ext == ".png" ? wxBITMAP_TYPE_PNG : wxBITMAP_TYPE_JPEG);
|
bitmap.LoadFile(path, ext == ".png" ? wxBITMAP_TYPE_PNG : wxBITMAP_TYPE_JPEG);
|
||||||
|
|
||||||
|
// check if the bitmap has a square shape
|
||||||
|
|
||||||
|
if (wxSize sz = bitmap.GetSize(); sz.x != sz.y) {
|
||||||
|
const int bmp_side = std::min(sz.GetWidth(), sz.GetHeight());
|
||||||
|
|
||||||
|
wxRect rc = sz.GetWidth() > sz.GetHeight() ?
|
||||||
|
wxRect(int( 0.5 * (sz.x - sz.y)), 0, bmp_side, bmp_side) :
|
||||||
|
wxRect(0, int( 0.5 * (sz.y - sz.x)), bmp_side, bmp_side) ;
|
||||||
|
|
||||||
|
bitmap = bitmap.GetSubBitmap(rc);
|
||||||
|
}
|
||||||
|
|
||||||
// set mask for circle shape
|
// set mask for circle shape
|
||||||
|
|
||||||
wxBitmapBundle mask_bmps = *get_bmp_bundle("user_mask", bitmap.GetSize().GetWidth());
|
wxBitmapBundle mask_bmps = *get_bmp_bundle("user_mask", bitmap.GetSize().GetWidth());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user