Fastest color addition with clamp 0-255 of RGB

fast add of two 24/32 bit color

lsb of RG component must be set too zero

public int addRGBColor(int color1,int color2)
{
 color1 &=0xFEFEFE; //set some lsb to 0
 color2 &=0xFEFEFE; //set some lsb to 0
 int color=color1+color2;  //add color
 color|=(( color>>8 ) &0x010101)*0xFF;  //clamp color to 0 - 255
}

this introduce a little error on lsb bits but it is very fast

Clever!

Any benchmarks compared it to using if statements to clamp?

Haha, neat =D