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

Re: [pygame] Apply alpha to another image



Stuart Axon wrote:
Hello,
 I'm wondering the best way to apply alpha from one surface onto another -

I can get the alpha with
pygame.surfarray.array_alpha

But can't see a corresponding way to apply that to a surface without
affecting the rgb values.

Basically I have two images, one paletted, I manipulate the palette
then blit it onto a 32 bit surface.
The second image has the alpha, I want to apply this to the surface,
keeping the rgb values - basically a very quick way of colourising
things.

Array slicing comes to the rescue.

pygame.surfarray.pixels_alpha(surf32)[...] = array_of_alpha

pixels_alpha() returns an array view of a surfaces alpha plane. The square brackets indicate assignment to the contents of the array. The ellipses represents the entire array.

--
Lenard Lindstrom
<len-l@xxxxxxxxx>