I am wondering what the ‘correct’ behavior of alphablitting should be.
From the Docs:
RGBA->RGBA with SDL_SRCALPHA The source is alpha-blended with the
destination using the source alpha channel. The alpha channel in the
destination surface is left untouched. SDL_SRCCOLORKEY is ignored.
RGBA->RGBA without SDL_SRCALPHA The RGBA data is copied to the destination
surface. If SDL_SRCCOLORKEY is set, only the pixels not matching the
colorkey value are copied.
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.
The problem I see here, is that the when SDL_SRCALPHA is enabled, and you
alphablit to a 100% transparant surface, you get nothing.
What I’m trying to do is assemble several alpha images into a single alpha
image (IE, overlaying them to form one alpha image)
But the behavior of both of these blitting modes are useless to accomplish
this.
I’ve been having to blit everything directly to the SW_Surface Video mode to
get the intended effect, and it’s incredably slow.
If SDL_SRCALPHA isn’t set, then it replaces the graphical data, which is
also useless for what I’m trying to do, since it replaces it.
Blitting to a non-alpha surface achives the intended effect, however has the
negative problem of not being able to overlay that surface over something
else.
What we need is a alpha blending that blends the images, but the resulting
alpha is only when both pixels in the images are transparent.
So If you blend two images, any part that is Opaque in both images, the
source image replaces that pixel. If the pixel in the source is opaque, but
the pixel in the destination is transparent it replaces the pixel. If both
of the pixels are transparent, they are blended and the alpha value is
recalculated. If the src image pixel is completely transparent and the the
destination pixel is transparent, the image retains the destinations alpha
value. If both images have completely transparent pixels, the final image
will retain the alpha value._________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com