[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Stuck with surfarray
On Mon, 19 Jul 2004, Pete Shinners wrote:
> Having a RGBA array would make this a little easier, but you certainly
> aren't stuck without it. If you want to swap the complete RGBA, use a
> "2D" array and the mapped colors.
>
> def swapRGBA(surf, srcRGBA, dstRGBA):
> array = pygame.surfarray.array2d(surf)
> src = surf.map_rgb(srcRGBA)
> dst = surf.map_rgb(dstRGBA)
> array = Numeric.where(array == src, dst, array)
> return pygame.surfarray.make_surface(array)
I hadn't considered that, thanks Pete!
Hmmm, actually I just wanted to swap the RGB, and leave the A intact. But I
think I can work this out with a more complicated Numeric.where()
-Jasper