At least an additive blitting would be needed. This means, RGB pixels are
overwritten and alpha values are added. In my project this would be useful
e.g. to add several circles with antialiased borders into one surface, before
they are blitted to the screen.
Just to make it clear, you are asking for
dest_RGB := src_RGB
dest_alpha := min(src_alpha + dest_alpha, 1.0),
right? It doesn’t quite seem right to me, since a low-alpha value written
over an opaque pixel would suddenly become entirely opaque (and thus have
its appearence changed completely). Or do you mean that the RGB values should
be added as well:
dest_RGB := min(src_RGB + dest_RGB, 1.0)
dest_alpha := min(src_alpha + dest_alpha, 1.0)
The above is the standard additive blitting (a.k.a. lighting, since it
simulates the result of two spots of light cast at the same place on a
white wall).
To composite several anti-aliased objects on an RGBA surface, people usually
want the classic alpha “over” operator, namely
dest_RGB := src_RGB * src_alpha + dest_RGB * (1 - src_alpha) * dst_alpha
dest_alpha := src_alpha + (1 - src_alpha) * dst_alpha
and this is all good, except that the resulting RGB colours now are
premultiplied and must be divided by the resulting alpha in order to
be blittable again. (If we start supporting premultiplied alpha in SDL
one day, and I’m getting more and more convinced that this is a good
thing, then this isn’t a problem.)
Another thing I am missing is the possibility for target color keying. To be true,
I have always asked myself, what this feature (possible in DirectX I believe)
is good for, but after exploring the files of baldurs gate with the infinity explorer,
I learned, that this is VERY useful for watersurfaces or other big animated
surfaces.
I presume you mean that a pixel should be drawn if and only if the
corresponding destination pixel is equal to a certain value. I can
certainly see the utility in this, but I wonder how well it could be
accelerated in hardware. Also, the naive implementation:
for(each x,y in image) {
if(destination(x,y) == colour_key)
destination(x,y) := source(x,y)
}
uses a read-modify-write cycle which would be nice to avoid. Perhaps
a target RLE mask would be useful for this?
Did I mentioned the hope for mask blittings with external masks?
Please explain this as well.
Cheers,
Mattias.