Blight
13th August 2002, 09:29
A bit out of topic,
I'm trying to think of the fastest way (non-asm/mmx) to do Integer Based Alpha Blending.
You have 2 RGB images and one 8-bit Alpha Image to controls the mix between the two images.
The best thing I could come up with is:
DestPixel = (Pixel1*(255-AlphaPixel)+Pixel2*AlphaPixel) / 255;
This keeps everything within the integer range, is there a better way I'm overlooking?
You could replace the "/ 255" with "shr 8", but then you'd lose 1/256 accuracy which I don't want.
I'm trying to think of the fastest way (non-asm/mmx) to do Integer Based Alpha Blending.
You have 2 RGB images and one 8-bit Alpha Image to controls the mix between the two images.
The best thing I could come up with is:
DestPixel = (Pixel1*(255-AlphaPixel)+Pixel2*AlphaPixel) / 255;
This keeps everything within the integer range, is there a better way I'm overlooking?
You could replace the "/ 255" with "shr 8", but then you'd lose 1/256 accuracy which I don't want.