diff options
| -rw-r--r-- | lib/python/Tools/LoadPixmap.py | 11 | ||||
| -rw-r--r-- | skin.py | 8 |
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/python/Tools/LoadPixmap.py b/lib/python/Tools/LoadPixmap.py index b7838a39..53e04e54 100644 --- a/lib/python/Tools/LoadPixmap.py +++ b/lib/python/Tools/LoadPixmap.py @@ -1,6 +1,11 @@ from enigma import loadPNG, loadJPG -def LoadPixmap(path, desktop = None): +pixmap_cache = {} + +def LoadPixmap(path, desktop = None, cached = False): + if path in pixmap_cache: + return pixmap_cache[path] + if path[-4:] == ".png": ptr = loadPNG(path) elif path[-4:] == ".jpg": @@ -12,4 +17,8 @@ def LoadPixmap(path, desktop = None): raise "neither .png nor .jpg, please fix file extension" if ptr and desktop: desktop.makeCompatiblePixmap(ptr) + + if cached: + pixmap_cache[path] = ptr + return ptr @@ -106,7 +106,13 @@ def collectAttributes(skinAttributes, node, skin_path_prefix=None, ignore=[]): skinAttributes.append((attrib, value)) def loadPixmap(path, desktop): - ptr = LoadPixmap(path, desktop) + cached = False + option = path.find("#") + if option != -1: + options = path[option+1:].split(',') + path = path[:option] + cached = "cached" in options + ptr = LoadPixmap(path, desktop, cached) if ptr is None: raise SkinError("pixmap file %s not found!" % (path)) return ptr |
