[OLPC-Games] Image resizing?
Luke Paireepinart
rabidpoobear at gmail.com
Thu Sep 6 03:46:43 EDT 2007
Roberto Fagá wrote:
> Thanks Luke, I don't know why I didn't think on using the original
> image. Resizing the original produces a good result, not filtered but
> its looks fine.
> About the tests, check for this:
>
> http://pera.ifsc.usp.br/faga/ppr.py
>
> change the images path and you can check, pygame's scale method is a
> bit slower, but nothing terrible, it's usable for games as converting
> from PIL to Pygame is slower than using only pygame's scale method.
>
> Oh, and rotozoom is too slower than scale, so use rotozoom only when
> you need to rotate.
>
> Here are the times I got as my example image, all operations doing 1000 times:
>
> ############
> PyGame:
> Time to load a picture: 41.1937s
>
> PIL:
> Time to load a picture: 0.4902s
>
These two numbers are a bit misleading - the loading of a picture is
handled differently between the libraries. PIL does a lazy load,
where it just opens a handle to the picture but doesn't read in any of
the data until the user performs an operation that needs the data.
Pygame reads in all data no matter what, and creates a Surface object to
hold it.
Also, look into the timeit module to more accurately time executions.
As far as the other numbers go, I believe that PIL is faster, as that's
all it's made to do.
You can always talk to the pygame people if you have ideas about
speeding up these functions.
I suspect there's something we don't know about that pygame is handling
for us that's making these take longer.
-Luke
More information about the Games
mailing list