public static int interpolateColor(double x,double y,int c0,int c1,int c2,int c3){
  int a0=(c0 >> 24) & 0xff;
  int r0=(c0 >> 16) & 0xff;
  int g0=(c0 >> 8) & 0xff;
  int b0=c0 & 0xff;
  int a1=(c1 >> 24) & 0xff;
  int r1=(c1 >> 16) & 0xff;
  int g1=(c1 >> 8) & 0xff;
  int b1=c1 & 0xff;
  int a2=(c2 >> 24) & 0xff;
  int r2=(c2 >> 16) & 0xff;
  int g2=(c2 >> 8) & 0xff;
  int b2=c2 & 0xff;
  int a3=(c3 >> 24) & 0xff;
  int r3=(c3 >> 16) & 0xff;
  int g3=(c3 >> 8) & 0xff;
  int b3=c3 & 0xff;
  double rx=1.0d - x;
  double ry=1.0d - y;
  double x0=rx * a0 + x * a1;
  double x1=rx * a2 + x * a3;
  int a=(int)(ry * x0 + y * x1);
  a=a << 24;
  x0=rx * r0 + x * r1;
  x1=rx * r2 + x * r3;
  int r=(int)(ry * x0 + y * x1);
  r=r << 16;
  x0=rx * g0 + x * g1;
  x1=rx * g2 + x * g3;
  int g=(int)(ry * x0 + y * x1);
  g=g << 8;
  x0=rx * b0 + x * b1;
  x1=rx * b2 + x * b3;
  int b=(int)(ry * x0 + y * x1);
  return (a | r | g| b);
}

public static int interpolateColor ( double x , double y , int c0 , int c1 , int c2 , int c3 ) { int a0 = ( c0 > > 24 ) & 0xff ; int r0 = ( c0 > > 16 ) & 0xff ; int g0 = ( c0 > > 8 ) & 0xff ; int b0 = c0 & 0xff ; int a1 = ( c1 > > 24 ) & 0xff ; int r1 = ( c1 > > 16 ) & 0xff ; int g1 = ( c1 > > 8 ) & 0xff ; int b1 = c1 & 0xff ; int a2 = ( c2 > > 24 ) & 0xff ; int r2 = ( c2 > > 16 ) & 0xff ; int g2 = ( c2 > > 8 ) & 0xff ; int b2 = c2 & 0xff ; int a3 = ( c3 > > 24 ) & 0xff ; int r3 = ( c3 > > 16 ) & 0xff ; int g3 = ( c3 > > 8 ) & 0xff ; int b3 = c3 & 0xff ; double rx = 1.0d - x ; double ry = 1.0d - y ; double x0 = rx * a0 + x * a1 ; double x1 = rx * a2 + x * a3 ; int a = ( int ) ( ry * x0 + y * x1 ) ; a = a << 24 ; x0 = rx * r0 + x * r1 ; x1 = rx * r2 + x * r3 ; int r = ( int ) ( ry * x0 + y * x1 ) ; r = r << 16 ; x0 = rx * g0 + x * g1 ; x1 = rx * g2 + x * g3 ; int g = ( int ) ( ry * x0 + y * x1 ) ; g = g << 8 ; x0 = rx * b0 + x * b1 ; x1 = rx * b2 + x * b3 ; int b = ( int ) ( ry * x0 + y * x1 ) ; return ( a | r | g | b ) ; }
performs bilinear interpolation of 32 - bit colors over a convex quadrilateral .
