speedup resolveFilename a bit
[enigma2.git] / lib / python / Tools / LoadPixmap.py
index b7838a39c1f4a206e72e9d26024f6cfdedbebf55..53e04e54eca00e410406bb97ea2335c153eef91a 100644 (file)
@@ -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