Alpha Blending using comparative rgb values. [Big picture warning]

BlitzPlus Forums/BlitzPlus Programming/Alpha Blending using comparative rgb values. [Big picture warning]

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.

Cheers for the suggestions guys. Somewhat spookily, the combination of these two resulted in me stumbling upon the (now obvious) difference between my Mocks and my Code. Turns out that I was doing things ever so slightly differently in PSP than my code was doing on its own.

I hadn't taken into account the colorisation of the luminance for each pixel. So my transparent pixels were too pure a sample of the intended color.. Or something.. :\

Anyway, having already done this with my Image Processing Functions, it was just a code adaption. :)

tempred# = Red_Level_1#/255
tempgreen# = Green_Level_1#/255
tempblue# = Blue_Level_1#/255

greylevel# = alphalevel1#*255
If greylevel# >= 128 Then
	redlevel1# = 255 * tempred# + (1-tempred#)*(greylevel#-(255-greylevel#))
	greenlevel1# = 255 * tempgreen# + (1-tempgreen#)*(greylevel#-(255-greylevel#))
	bluelevel1# = 255 * tempblue# + (1-tempblue#)*(greylevel#-(255-greylevel#))
Else
	redlevel1# = Int(greylevel#*tempred#)*2
	greenlevel1# = Int(greylevel#*tempgreen#)*2
	bluelevel1# = Int(greylevel#*tempblue#)*2
End If

redlevel# = redlevel# - ((redlevel# - redlevel1#)*alphalevel1#)
greenlevel# = greenlevel# - ((greenlevel# - greenlevel1#)*alphalevel1#) 
bluelevel# = bluelevel# - ((bluelevel# - bluelevel1#)*alphalevel1#)


Thanks again.

Now, saying all that. It would be nice to come up with an "Additive" and "Multiplicative" version of alpha-transparency, so if anyone's got any ideas on where to begin I'd be very interested.