private void interpolate(int rgb1,int rgb2,int[] output){
  int a1, r1, g1, b1, da, dr, dg, db;
  float stepSize=1.0f / output.length;
  a1=(rgb1 >> 24) & 0xff;
  r1=(rgb1 >> 16) & 0xff;
  g1=(rgb1 >> 8) & 0xff;
  b1=(rgb1) & 0xff;
  da=((rgb2 >> 24) & 0xff) - a1;
  dr=((rgb2 >> 16) & 0xff) - r1;
  dg=((rgb2 >> 8) & 0xff) - g1;
  db=((rgb2) & 0xff) - b1;
  for (int i=0; i < output.length; i++) {
    output[i]=(((int)((a1 + i * da * stepSize) + 0.5) << 24)) | (((int)((r1 + i * dr * stepSize) + 0.5) << 16)) | (((int)((g1 + i * dg * stepSize) + 0.5) << 8))| (((int)((b1 + i * db * stepSize) + 0.5)));
  }
}

private void interpolate ( int rgb1 , int rgb2 , int [ ] output ) { int a1 , r1 , g1 , b1 , da , dr , dg , db ; float stepSize = 1.0f / output . length ; a1 = ( rgb1 > > 24 ) & 0xff ; r1 = ( rgb1 > > 16 ) & 0xff ; g1 = ( rgb1 > > 8 ) & 0xff ; b1 = ( rgb1 ) & 0xff ; da = ( ( rgb2 > > 24 ) & 0xff ) - a1 ; dr = ( ( rgb2 > > 16 ) & 0xff ) - r1 ; dg = ( ( rgb2 > > 8 ) & 0xff ) - g1 ; db = ( ( rgb2 ) & 0xff ) - b1 ; for ( int i = 0 ; i < output . length ; i ++ ) { output [ i ] = ( ( ( int ) ( ( a1 + i * da * stepSize ) + 0.5 ) << 24 ) ) | ( ( ( int ) ( ( r1 + i * dr * stepSize ) + 0.5 ) << 16 ) ) | ( ( ( int ) ( ( g1 + i * dg * stepSize ) + 0.5 ) << 8 ) ) | ( ( ( int ) ( ( b1 + i * db * stepSize ) + 0.5 ) ) ) ; } }
yet another helper function . this one linearly interpolates between 2 colors , filling up the output array .
