2006-06-20, 11:11
hello. over the past week i've started looking at how to modify an existing xbmc script so that it will cache images rather than having to spin up the hd when it needs to display a controlimage.
this is the original bit of script to put the image on the screen:
the way i thought i could achieve the cache is to stick the controlimage into an array, and pull it out of the array (which i assumed would be in memory) to write it to the screen, e.g.
despite all this, when it adds the control to the screen the hard drive will spin up. is this a limitation with controlimages? or is there a technique to make cached images work?
many thanks in advance,
matt.
this is the original bit of script to put the image on the screen:
Quote:self.frame = xbmcgui.controlimage(w - 359, h - 138, 77, 103, 'someimage.jpg')
self.addcontrol(self.frame)
the way i thought i could achieve the cache is to stick the controlimage into an array, and pull it out of the array (which i assumed would be in memory) to write it to the screen, e.g.
Quote:preloadedimages = {} # used to pre-load images
def cacheimage(x, y, w, h, the_filename):
global preloadedimages
preloadedimages[the_filename] = xbmcgui.controlimage(x, y, w, h, scriptfolder + the_filename)
def cacheimages(w, h):
cacheimage(w - 282, h - 138, 222, 103, imagedialog)
def cachedimage(the_filename):
global preloadedimages
return preloadedimages[the_filename]
class initialise(xbmcgui.windowdialog):
def (self):
w = self.getwidth()
h = self.getheight()
cacheimages(w, h)
class main(xbmcgui.windowdialog):
def (self):
self.bg = cachedimage(imagedialog)
self.addcontrol(self.bg)
despite all this, when it adds the control to the screen the hard drive will spin up. is this a limitation with controlimages? or is there a technique to make cached images work?
many thanks in advance,
matt.