[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Simpler scaling method with surfarray



Fábio Dias wrote:

> I've been playing with the surfarray module and, after perusing the Numeric 
> docs, I have found another method to scale up an image besides the one on the 
> surfarray tutorial, faster and simpler:
> 
>     if imgarray.shape[0] >= imgarray.shape[1]:
>         scaleup = N.repeat(N.repeat(imgarray, 4, 1), 4, 0)
>     else:
>         scaleup = N.repeat(N.repeat(imgarray, 4, 0), 4, 1)

nice. i should drop this into my flame example, since that needs all the 
speed it can get. :]
i wonder how this compares the the pygame.transform.scale function? this 
scaling is a little optimized for integer multiplies of the original 
size, but my guess is it will be about the same performance as the 
transform.scale

<<time and curiousity pass...>>

ahh.. i've just come back with a little conclusive testing. I took the 
flame example and plugged in this different scaling. it turns out to be 
not much different in the case of "flames". likely because it is only 
doing a 2x scale, and scaling isn't a bigger part of the runtime?

in similar news, i just tried using pygame.transform.scale to double
the image size, and the framerate really lifted. i went from 74 fps
up to 114 fps, about 60% improvement! in light of that exciting changed, 
i've resubmitted flames to the PCR with a slightly bigger window and a
faster framerate.


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org