I'm trying to write a cheap 'n' cheerful 24-bit alpha blending algorithm. I've so far got:-
This doesn't seem to give 100% of the desired effect unfortunately, as bright colours appear with increasing alpha. It's also worth noting that I'm testing this by using empty (Black) source data against a destination image (To fade the image). Might black blending be a special case? :confused:
(iAlpha is alpha level, 0 to 255)
(lpSrc is an unsigned char pointer to source data)
(Guess what lpDest is)
unsigned long ulColour;
("For each pixel:")
ulColour = iAlpha * ((*(lpSrc++) - *lpDest) >> 8) + *lpDest;
*(lpDest++) = (unsigned char)ulColour;
Never mind, I've sorted it out. Where alpha results were more than 255 or less than 0 nothing was being done to rectify the result within bounds. it works now (Albeit quite slow, I think I'll need to assemblerise it at some stage). :D
Post your code. I'm sure you don't need to convert it to ASM... although perhaps storing the information in another file after you've computed it and then using that in the future would be a good idea.
If you want it to be fast, forget assembler and use Direct3D.