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":
raise "neither .png nor .jpg, please fix file extension"
if ptr and desktop:
desktop.makeCompatiblePixmap(ptr)
+
+ if cached:
+ pixmap_cache[path] = ptr
+
return ptr
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