From 72089a1844b6b6e820601d00c028b774dc0cbf75 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Sat, 15 Mar 2008 10:50:29 +0000 Subject: optional pixmap caching --- lib/python/Tools/LoadPixmap.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib/python') 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 -- cgit v1.2.3