Reducing pygame cpu-load to < 4 %

Noah Kantrowitz kantrn at rpi.edu
Sun Dec 9 21:05:32 EST 2007


The surf.convert() and .convert_alpha() will do this. It is advised to
always run one of these (depending on if you need per-pixel alphas) on
any image loaded from disk.

--Noah

Bernardo Innocenti wrote:
> On 12/09/07 19:08, Noah Kantrowitz wrote:
>> Unfortunately this is not possible in most games, as doing them purely
>> vector-based is infeasible. A lot of the artwork made for games will be
>> standard raster graphics, and will need to be designed for a specific
>> screen. If there are changes in the future, they can always be redrawn.
>
> The conversion to the screen format can happen at load
> time, rather than each time the bitmap is being redrawn
> on screen.
>
> Doing it systematically is very easy:
>
>  Surface *load_image(const char *filename)
>  {
>      Surface *s = NULL, tmp;
>
>      if ((tmp = IMG_Load(filename))
>      {
>          s = SDL_DisplayFormat(tmp);
>          SDL_FreeSurface(tmp);
>      }
>      return s;
>  }
>
> Some libraries, notably SDL, make blitting graphics between
> different pixel formats a little bit too transparent.
> As a result, developers don't even notice and huge performance
> bugs like this slip through.
>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
URL: <http://lists.laptop.org/pipermail/devel/attachments/20071209/cdd93a9a/attachment.sig>


More information about the Devel mailing list