[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] surfarray & alpha



> It seems like the alpha support in surfarray is missing the inverse to
> surfarray.pixels_alpha() and surfarray.array_alpha().  Or am I missing
> something obvious?

with a pixels_alpha() array, you can assign the entire array (or
slices of) to another array with the standardish python idiom

thealpha = pygame.surfarray.pixels_alpha(mysurface)
thealpha[:] = make_trapezoid()

this will do what you want, and run very quick too.

the only drawback might be pixels_alpha() only works on
32bit surfaces. this leaves a bit of a hole in the surfarray
functionality; there's no way to easily assign the alpha 
channel on a non-32bit image.

well, technically it can be done with a little bitwise magic
on the 2d arrays :]


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org