MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / loadBitmap

Method loadBitmap

gui/bitmap_loader.py:90–108  ·  view source on GitHub ↗
(cls, name, location)

Source from the content-addressed store, hash-verified

88
89 @classmethod
90 def loadBitmap(cls, name, location):
91 if cls.scaling_factor is None:
92 cls.scaling_factor = 1 if 'wxGTK' in wx.PlatformInfo else int(wx.GetApp().GetTopWindow().GetContentScaleFactor())
93 scale = cls.scaling_factor
94
95 filename, img = cls.loadScaledBitmap(name, location, scale)
96
97 while img is None and scale > 0:
98 # can't find the correctly scaled image, fallback to smaller scales
99 scale -= 1
100 filename, img = cls.loadScaledBitmap(name, location, scale)
101
102 if img is None:
103 pyfalog.warning("Missing icon file: {0}/{1}".format(location, filename))
104 return None
105
106 if scale > 1:
107 return img.Scale(round(img.GetWidth() // scale), round(img.GetHeight() // scale)).ConvertToBitmap()
108 return img.ConvertToBitmap()
109
110 @classmethod
111 def loadScaledBitmap(cls, name, location, scale=0):

Callers 1

getBitmapMethod · 0.80

Calls 3

loadScaledBitmapMethod · 0.80
GetWidthMethod · 0.45
GetHeightMethod · 0.45

Tested by

no test coverage detected