Cn : value of color to interpolate
BX : interpolation ratio X => must range beteen 0-255
BY : interpolation ratio Y => must range beteen 0-255
public int interpolate(int c1,int c2,int c3,int c4,int bX, int bY)
{
int f24=(bX*bY)>>8;
int f23=bX-f24;
int f14=bY-f24;
int f13=((256-bX)*(256-bY))>>8; // this one can be computed faster
return ((((c1&0xFF00FF)*f13+(c2&0xFF00FF)*f23+(c3&0xFF00FF)*f14+(c4&0xFF00FF)*f24)&0xFF00FF00)|
(((c1&0x00FF00)*f13+(c2&0x00FF00)*f23+(c3&0x00FF00)*f14+(c4&0x00FF00)*f24)&0x00FF0000))>>>8;
}