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

Re: [pygame] Fast Blit with mask



On Sun, 2005-11-27 at 19:23 -0800, Knapp wrote:
> I need to have 3 surfaces.
> A is the main image
> B is the mask. This would be a round hole that moves around like
> looking through a gun sight on a surface the same size as A.
> C would be the screen surface.

If your mask is truly two colors (no anti aliasing or anything) you can
do this with a double blit technique. Your mask will need to use colors
not included in the image you are masking.

If your mask is white in the areas to use, and black where it should
ignore, do this style code.


tmpImage = srcImage.copy()
maskImage.set_colorkey(0x000000)
tmpImage.blit(maskImage, (0, 0))
tmpImage.set_colorkey(0xffffff)
screen.blit(tmpImage)