I used the python timeit module, and blitted the image 100k times on an 800x600 32bpp SW screen surface (default flags). These times are averaged over several runs.
Time to blit unoptimized (straight from image.load): 23.7 sec Time to blit with convert_alpha(): 3.0 sec Time to blit with convert_alpha() and set_alpha(0, pygame.RLEACCEL): 2.8 secThis is just one image which has large areas that are completely transparent and completely opaque and blended transparency around the edges.
For grins I also tried it with a fullscreen surface (FULLSCREEN | HWSURFACE | DOUBLEBUF) (which on macosx is a sw surface, but I use the HWSURFACE flag hack to get SDL to use its experimental high perf fullscreen macosx mode). The results are generally faster, but the lesson is the same:
no optimization: 22.0 sec convert_alpha() only: 2.7 sec convert_alpha() and RLEACCEL: 2.0 secSo convert_alpha() is a huge win, and RLEACCEL is some icing on the cake. Granted this is just one example image, but I thought it was worth sharing.
-Casey On Sep 14, 2007, at 2:05 AM, Ulf Ekström wrote:
If you do software surface blitting you can speed up the alpha blending a lot by using RLE encoding of the transparent surface. I suppose there is special code in there for the case of completely transparent or completely opaque pixels. You can use it with by doing something like surface.set_alpha(0, pygame.RLEACCEL), but I must admit I have only used this with the C SDL functions, so perhaps someone can fill in the details. The '0' is ignored when the the surface has per pixel alpha. Transparent edges of sprites really look much much better than hard edges, compare for examplehttp://offload2.icculus.org/airstrike/screenshots/ohmygod.png (no alpha)with http://offload2.icculus.org/airstrike/screenshots/screenshot5.png (per pixel alpha) You can generate the soft edges by asking your artist to draw the sprites in high resolution, on a transparent background, and then scale them down. Regards, Ulf