[SDL] blitting from-to surface with per-pixel alpha doesn't work...

Gabriel mystml at adinet.com.uy
Thu Nov 17 16:48:29 PST 2005


> All of the images are PNGs with initial transparency fill from Gimp.
> The blit is working great with per-pixel alpha but only when I blit the
> parts into 'display', not to the 'tank' and then to 'display' surface.

Wait, wait. When you said "screen<-tank<-parts" I assumed you meant
"(screen <- tank) <- parts". If you meant "screen <- (tank <- parts)"
then you're correct, SDL doesn't work as you expect - the SDL_SetAlpha
docs say "Note that RGBA->RGBA blits (with SDL_SRCALPHA set) keep the
alpha of the destination surface. This means that you cannot compose two
arbitrary RGBA surfaces this way and get the result you would expect
from "overlaying" them; the destination alpha will work as a mask."

I have encountered this problem before, as many other people have; the
general consensus seems to be to code that blit manually, using whatever
alpha semantics you want. Since I only do this at load time, it doesn't
matter that it isn't optimized. 

It may be a good idea to have at least a non-optimized function in SDL
to do this. Everyone : what kind of operation should be done for an
hypotethical SDL_ComposeSurface()?


-- 
Gabriel Gambetta
Mystery Studio - http://www.mysterystudio.com
Gabriel on Graphics - http://gabrielongraphics.blogspot.com





More information about the SDL mailing list