[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Simple Surfarray Alpha
- To: "pygame-users@xxxxxxxx" <pygame-users@xxxxxxxx>
- Subject: [pygame] Simple Surfarray Alpha
- From: Ian Mallett <geometrian@xxxxxxxxx>
- Date: Sat, 7 Feb 2009 10:22:06 -0800
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sat, 07 Feb 2009 13:22:09 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=bAomXv/uY+sNSvY+uj8i80LaD3CuTku193ex90CK+bY=; b=Bmd3GgrZZb2RIEe8SXA1Vac+kNZ4lS/Fn6reSdBC1szcpH+XDIk2e7T7ORkFjyCCKK ffhln2XHtI3JEhxvQYy+AMocSpyeUpUCk1at6mwCGyU442kl375J111thSW5BnrGHJqW 3U7ibLt80YqJXmd5MTYZqyhkmPlLAokca0vyA=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=AMcO/74WmVZtzTl66Dcs2OFG5OfbD/qGjq6A7IFXabxZgHpqGye39RUa6hrsmvNDDz gcGGBlr+bX24gWhU4BnDad/5JdrqPUYflih18G/UGxOY3mA/vB71d1dPam5ICXETaaug qUKt3M65P/sc2FBzdb0m+uGmtX4i993ee6LPo=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Hello,
I need to make a function where the alpha value of a surface is flipped. I can already do this with the red, green, or blue channels:
#red flip
array = pygame.surfarray.pixels3d(surface)
array[:,:,0] = 255-array[:,:,0]
del array
#green flip
array = pygame.surfarray.pixels3d(surface)
array[:,:,1] = 255-array[:,:,1]
del array
#blue flip
array = pygame.surfarray.pixels3d(surface)
array[:,:,2] = 255-array[:,:,2]
del array
#rgb flip
array = pygame.surfarray.pixels3d(surface)
array[:,:,:] = 255-array[:,:,:]
del array
I can't do the alpha flip though. I tried:
array = pygame.surfarray.pixels_alpha(surface)
array[:,:] = 255-array[:,:]
del array
but it raises an error.
Ideas?
Thanks,
Ian