[pygame] Blitting image with alpha channel on a transparent background

2010-04-22 Thread stas zytkiewicz
Hello, I hope that someone can point me in the right direction. I have a semi transparent background surface created with set_alpha(100). On this surface I want to blit an png image which has a alpha channel. The problem is that when I blit the png image surface to the background surface the png

Re: [pygame] Blitting image with alpha channel on a transparent background

2010-04-22 Thread Lee Buckingham
If there's no images being displayed behind the background image, then there isn't a need for it to have an alpha value at all, since you'd never see anything through it anyway. As far as the alpha goes, my guess is that you're getting hung up because you've mixed two different alpha modes.

Re: [pygame] Blitting image with alpha channel on a transparent background

2010-04-22 Thread stas zytkiewicz
On Thu, Apr 22, 2010 at 6:56 PM, Lee Buckingham lee.bucking...@gmail.com wrote: As far as the alpha goes, my guess is that you're getting hung up because you've mixed two different alpha modes.  There's some caveats about using per-pixel alpha (like the .png file probably has) and the other

Re: [pygame] Blitting image with alpha channel on a transparent background

2010-04-22 Thread Lee Buckingham
Instead of using set_alpha(), try using a fill, like: backgroundsurface.fill((0,0,0,100)) that should make the background use per-pixel alpha too, since there's a fourth number in the color (for alpha) so blitting another per-pixel alpha image shouldn't cause problems. Hmm... maybe I'll try

Re: [pygame] Blitting image with alpha channel on a transparent background

2010-04-22 Thread Lee Buckingham
yeah, that worked for me, here's my (messy) example code: import pygame from pygame.locals import * import os pygame.init() screen = pygame.display.set_mode((100,100)) screen.fill([0, 0, 0]) # blank the screen. #random image fartherback = pygame.image.load(os.path.join(Images,

Re: [pygame] Blitting image with alpha channel on a transparent background

2010-04-22 Thread Greg Ewing
Lee Buckingham wrote: Instead of using set_alpha(), try using a fill, like: backgroundsurface.fill((0,0,0,100)) Note that you will also have to create the background surface with the SRCALPHA flag, so that it will have a per-pixel alpha channel. If you don't use that flag, then the surface

Re: [pygame] Blitting image with alpha channel on a transparent background

2010-04-22 Thread stas zytkiewicz
On Fri, Apr 23, 2010 at 2:59 AM, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Lee Buckingham wrote: Instead of using set_alpha(), try using a fill, like:  backgroundsurface.fill((0,0,0,100)) Note that you will also have to create the background surface with the SRCALPHA flag, so that it