too many load_pil_image calls?
Hi, this code https://gist.github.com/4191121 tries to dynamically build up an image and display it at each step. It calls load_pil_image once for every invocation of Scene.draw. I'm guessing this is too much, because pythonista crashes after a short while. Is there a better way to do something like this? Is there a way to unload a loaded image?
There's currently no way to unload images loaded via load_pil_image, though it's probably a very good idea to add something like that.
I think it would be better if it was implemented like this:
# Instantiate PIL image object into pythonista imgObj = load_pil_image(...) image(imgObj, x, y, w, h) # x, y, w, h could be a Rect called bounds instead # OR imgObj.draw(x, y, w, h) # Release the used resources of the image object del imgObj
The same should be done for all image loading mechanisms, not just PIL ones.
Yes, probably. The PIL integration for the scene module was kind of an after-thought and using strings had some advantages at first (mostly being easier for novice users).