[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] SDL vs. Pygame: Alpha Differences



On 12/23/06, Kamilche <kamilche@xxxxxxxxxxxx> wrote:
Thanks for modifying that example. I see this is a variant on the other
technique that was posted, but involves a couple more blits to preserve
the alpha. I was trying to avoid all these extra blits to preserve the
alpha, as it slows down nighttime by quite a lot.

I don't know how this relates to your older question about darkening,
but this example does exactly what you asked for in the post that I
was replying to.

It shows how to use pygame to get SDL to blit exactly the way it is
described in the SDL docs.

The case I modified (case 3) does 3 things:
1. copy the source art to a temp (including the source's alpha)
2. blit to the temp, darkening the color without modifying the alpha
of the dest (the temp)
3. blit the temp to the background

I suppose if there was a colorized blit, you could do that in a single
blit without using a temp, but isn't it what you were asking for? (in
particular, there is no "extra" step to copy the original alpha back
to the temp)


Basically - I would dearly love a single blit from one picture to
another, to NOT modify the destination alpha, without require extra
blits or manipulation, but I guess that's not available.

That's exactly what the example I sent did...

In particular these lines do a blit from one picture to another, which
darkens the color without modifying the destination alpha:

 dest.set_alpha(None)
 src.set_alpha(255)
 dest.blit(src, (0,0))

It's like what Pete was emailing about - turning off the SDL_SRCALPHA
flag on the dest, so that the pygame code would call straight to SDL,
and then SDL seems the SDL_SRCALPHA on the source so it knows to blend
the colors but leave the alpha