Merge branch 'hd-images' into release/v2.5.0
This commit is contained in:
@@ -45,6 +45,8 @@ class BitmapLoader(object):
|
||||
dont_use_cached_bitmaps = False
|
||||
max_cached_bitmaps = 500
|
||||
|
||||
scaling_factor = None
|
||||
|
||||
@classmethod
|
||||
def getStaticBitmap(cls, name, parent, location):
|
||||
static = wx.StaticBitmap(parent)
|
||||
@@ -54,9 +56,7 @@ class BitmapLoader(object):
|
||||
@classmethod
|
||||
def getBitmap(cls, name, location):
|
||||
if cls.dont_use_cached_bitmaps:
|
||||
img = cls.getImage(name, location)
|
||||
if img is not None:
|
||||
return img.ConvertToBitmap()
|
||||
return cls.loadBitmap(name, location)
|
||||
|
||||
path = "%s%s" % (name, location)
|
||||
|
||||
@@ -64,11 +64,7 @@ class BitmapLoader(object):
|
||||
cls.cached_bitmaps.popitem(False)
|
||||
|
||||
if path not in cls.cached_bitmaps:
|
||||
img = cls.getImage(name, location)
|
||||
if img is not None:
|
||||
bmp = img.ConvertToBitmap()
|
||||
else:
|
||||
bmp = None
|
||||
bmp = cls.loadBitmap(name, location)
|
||||
cls.cached_bitmaps[path] = bmp
|
||||
else:
|
||||
bmp = cls.cached_bitmaps[path]
|
||||
@@ -77,8 +73,34 @@ class BitmapLoader(object):
|
||||
|
||||
@classmethod
|
||||
def getImage(cls, name, location):
|
||||
filename = "{0}.png".format(name)
|
||||
return cls.getBitmap(name, location).ConvertToImage()
|
||||
|
||||
@classmethod
|
||||
def loadBitmap(cls, name, location):
|
||||
if cls.scaling_factor is None:
|
||||
import gui.mainFrame
|
||||
cls.scaling_factor = int(gui.mainFrame.MainFrame.getInstance().GetContentScaleFactor())
|
||||
scale = cls.scaling_factor
|
||||
print(cls.scaling_factor)
|
||||
filenameScaled = "{0}@{1}x.png".format(name, scale)
|
||||
img = cls.loadImage(filenameScaled, location)
|
||||
|
||||
if img is None:
|
||||
# can't find the scaled image, fallback to no scaling
|
||||
filename = "{0}.png".format(name)
|
||||
img = cls.loadImage(filename, location)
|
||||
scale = 1
|
||||
|
||||
if img is None:
|
||||
return None
|
||||
|
||||
bmp: wx.Bitmap = img.ConvertToBitmap()
|
||||
if scale > 1:
|
||||
bmp.SetSize((int(bmp.GetWidth()/scale), int(bmp.GetHeight()/scale)))
|
||||
return bmp
|
||||
|
||||
@classmethod
|
||||
def loadImage(cls, filename, location):
|
||||
if cls.archive:
|
||||
path = os.path.join(location, filename)
|
||||
if os.sep != "/" and os.sep in path:
|
||||
|
||||
Reference in New Issue
Block a user