[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] palletized surfaces



Jason Ward wrote:
Hi
whenever I am calling get_pallete it tells me that the surface is not
palletised. But I have no clue how to make a surface
palletised, I can't find it in the docs.
Would surfarray be faster than using palletes to update entire surfaces?
Should I use numpy, surfarray, numeric or palletes to update entire
surfaces? (the fastest is the best imo)

From the Pygame 1.8 docs: "The Surface has a fixed resolution and pixel format. Surfaces with 8bit pixels use a color palette to map to 24bit color."

>>> import pygame
>>> s = pygame.Surface((10, 10), 0, 8)
>>> p = s.get_palette()
>>> len(p)
256
>>> type(p)
<type 'tuple'>
>>> p[0]
(0, 0, 0)

The Surface.convert method will palettise a non-palette image, but only after pygame.init() is called. I don't know what you mean by update an entire surface. A palette provides a fast way to change colors in an image.

--
Lenard Lindstrom
<len-l@xxxxxxxxx>