Re: [Pipmak-Users] This code show the image-cache-bug...
Status: Alpha
Brought to you by:
cwalther
From: Christian W. <cwa...@gm...> - 2008-01-03 10:59:04
|
[For those who only read -users: This is a continuation of a thread=20 started on pipmak-devel. I'm moving it here because I'm interested in=20 feedback from everyone. Read the beginning here:=20 <http://thread.gmane.org/gmane.games.devel.pipmak.devel/77>.] I wrote: > What trips you up is this (from section 3.12 "Image Manipulation" of th= e=20 > reference): > "pipmak.loadimage(filename) ... Calling this function multiple times=20 > with the same path returns the same object, and the image is only=20 > reloaded from disk if it isn=92t already in memory." >=20 > ... >=20 > I'm not sure what the best solution to this is. I don't think giving up= =20 > the returns-the-same-object behavior of pipmak.loadimage is a good idea= ,=20 > as I rely on it in many places. I'll try to think of something better I'm still pondering the copy-on-write thing, but here's another solution:= - Rename pipmak.loadimage to pipmak.getimage to emphasize its behavior=20 (keeping the old name around for backwards compatibility). - Disallow modification of images gotten from pipmak.getimage - if you=20 want to draw on an image, you must create it using pipmak.newimage. - Allow pipmak.newimage to be called with a path instead of width and=20 height, to initialize the new image from a file. What do you think? This would be simpler to implement, but would complicate things from the = point of view of the user, by dividing image objects into two classes. -Christian |