pygame is
Simple DirectMedia Layer is
Site Swing

applies_alpha() -

josmiley / Luke spywoker (mutualaccount)



not a project, just a trick
how to applies alpha channel from a surface to another ?
surface1 and surface2 must have the same size

from pygame import *
def applies_alpha(surface1,surface2):
#return a surface
#applies the alpha channel from surface1 to surface2
output = surface2.copy().convert_alpha()
surfarray.pixels_alpha(output)[:] = surfarray.array_alpha(surface1)[:]
return output

def applies_alpha_ip(surface1,surface2):
#applies the alpha channel in place from surface1 to surface2
  surfarray.pixels_alpha(surface2)[:] = surfarray.array_alpha(surface1)


Home Page:


click to view original size


applies_alpha() -  - Sep 7, 2010 account Comments

If you wish to leave a comment with your account, please sign in first.

No user comments have been submitted.

our projects welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
recent releases
Nov 17, 2015

Nov 12, 2015

Nov 11, 2015

Nov 8, 2015

Oct 16, 2015

Oct 9, 2015

Sep 11, 2015

Sep 6, 2015

Aug 26, 2015

Aug 25, 2015

... more!
for pygame related questions, comments, and suggestions, please see help (lists, irc)