combining 2 pixmaps, including alpha

BlitzMax Forums/BlitzMax Programming/combining 2 pixmaps, including alpha

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

In that case, one possibility would be (on a per pixel base):

colorRGB = colorRGB1 * alpha1/255.0 + colorRGB2 * alpha2/255.0
colorAlpha = (alpha1 + alpha2)/2.0

A different approcha is the 1 minus alpha that is used by BMs alphablend. (mixing by colorRGB1 * alpha1/255.0 + colorRGB2 * (255-alpha1)/255.0 ) but that does not preserve alpha as it mixes the color basing on the first (overlay) images alpha.

Problem I see (or at least do not seem to understand) is the preserve alpha layer.
There are 2 reasons for that:

1. Alpha is no layer but a color like Red Green and Blue
2. If both images have alpha, which ones alpha do you want to preserve?