[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Overwrite color not alpha?
Brian Fisher wrote:
SDL has some possibly non-intuitive rules about how to do the blit
ased on whether the SDL_SRCALPHA flag is set on the source and whether
the source and dest are RGB or RGBA. I don't know if you can find that
info in the pygame docs or not (anybody know?) but it is in the SDL
documentation for SDL_SetAlpha
here's a random version of that doc page
http://manuals.thexdershome.com/SDL-1.2.5/html/sdlsetalpha.html
Oh what a relief! Thanks for that page. I knew there were differences in
blitting alpha, I've tripped over them many times in the past, but I
never knew what the rules were.
BTW, I finally gagged down Pete Shinner's surfarray and Numeric
tutorial. It's time. :-D This line ended up letting me modify the color
of an RGBA surface, while preserving the alpha channel:
pygame.surfarray.pixels3d(pic)[:, :, :3] = (255,0,0)
where 'pic' is the pygame surface, and (255,0,0) is the color red.