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

Re: [pygame] alpha (fading) with surfarray



Markus Friedl wrote:
> I have some "strange" problems when trying to do per-pixel alpha 
> blending in combination with numeric... Hope anybody of you could give 
> me a hint... ;)
>
> one problem is that as soon as my "fade-factor" is bigger than 0.5 I get 
> an integer-overflow???

hmm, your function seems to be doing a lot of things. i'll try to 
stir up a simple part of the function.

def fadealpha(image, amount):
     'fade alpha by any amount, 0 to 255'
     assert image.get_masks()[3]  #has pixel alpha
     alpha = pygame.surfarray.array_alpha(image)
     fadealpha = minimum((alpha * amount) >> 8, 255)
     alpha[:] = fadealpha.astype('b')

(hopefully this works, my email is less picky on syntax than python)

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