Question

When you create a new Pygame surface:

pygame.Surface((width, height), flags=0, depth=0, masks=None)

Do you have to call .convert() on it to change its pixel format, or is that already done for you when you create it?

Was it helpful?

Solution

convert is only used when changing pixel formats (for example, going from indexed to rgb). The surface will be created with RGB by default and you should only need to convert it if that isn't what you need (it almost always is).

OTHER TIPS

When you create a new surface, its format always matches (as best it can) the format of the current display surface (whatever you set when you called pygame.display.set_mode() last). You won't need to convert new surfaces unless their format demands will differ from the display surface (alpha, for one, or indexed colour, as Name mentioned).

Note that if the new surface does have per-pixel alpha depth (with or without other format particulars), you will want to use convert_alpha() instead.

From the docs: http://www.pygame.org/docs/ref/surface.html (Which may have been updated in the almost twenty months since the question was asked.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top