I'm trying to do background loading of images out of the idle callback.
I was using pixbuf new_from_file, but that creates a two second blockage (I'm loading 3.5mb 3648x2736 jpegs).
So I switched to using a bixbufloader, what I discovered then is that reading the file off the drive and shoving it into the loader takes 10's of milliseconds. And calling close on the loader creates another 2 second blockage.
This is with pygtk 2.28.3 on windows 7 64bit with python2.7 and gtk 2.24.10.
Comments are typical run times in milliseconds.
Code:
import time
import gtk
last_time = time.time()
def mark(val):
global last_time
print val, time.time() - last_time
last_time = time.time()
pbl = gtk.gdk.PixbufLoader() # 0ms
mark(1)
data = open("slow.jpg", "rb").read() # 53ms
mark(2)
pbl.write(data) # 2ms
mark(3)
pbl.close() # 2132ms
mark(4)
pb = pbl.get_pixbuf() # 1ms
mark(5)
Is this expected behavior?
Am I doing something wrong?
Is there some library that needs to be installed for faster image processing?
Is trying to load images out of the idle callback just wrong headed to start with?
G