yet an other fastest....

this is inlined in 3DzzD so I hope to hadn't made any typos' while typing this function

NB: I may have found a faster method while reviewing this one.... so I will keep this thread up shortly

/**

* Blend two color

*

* blend two RGB colors using a blend factor

*

* 0 => return color 1

* n => return color2*(n/256) + color1*(256-n)/256

* 256 => return color 2

*

*

* NB : should be inlined for better efficiency

*

* @param color1 RGB color input 1

* @param color2 RGB color input 2

* @param factor blending factor between color1 & color 2, must be 0>=factor<=256

*

* @return color1 blended with color2

*

* @see

http://dzzd.net/ * @author Bruno Augier - ( DzzD ) - 2009

*/

public int blend(int color1,int color2, int factor)

{

int f1=256-factor;

return ( ( ( (c1&0xFF00FF)*f1 + (c2&0xFF00FF)*factor ) &0xFF00FF00 ) | ( ( (c1&0x00FF00)*f1 + (c2&0x00FF00)*factor ) &0x00FF0000 ) ) >>>8;

}

EDIT : error on factor range (256 max rather thn 255)

Others :

**50% blend :**Nice. =D

For 50% blending, I kinda like this:

res = ((c1&0xfefeff)+(c2&0xfefeff))>>1;

There's a slight error in the R and G channels, but it's very fast.