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

Re: [pygame] ChangeColor Routine



Tom Flanagan wrote:
Hi,
This is what i'm using to change an image's colors with Numeric:

        array  = pygame.surfarray.array3d(image)
        array  = array * color
        array  /= 255
        pygame.surfarray.blit_array(image, array)

where color = (R, G, B);


Huh. That is really amazing. It's difficult to figure out, but I timed it against my own routine, and it's super-fast! My routine is faster, but it only works on 256 color images. It involves getting the palette, modifying the entries, setting the palette, then converting the surface to the desired bit depth.

Yours will come in infinitely handy when I'm supplied a full color
image, as opposed to a 256 color image. Thank you so much for the tip. :-)

--Kamilche