Android Utililty Methods Color Average

List of utility methods to do Color Average


The list of methods to do Color Average are organized into topic(s).


intaverage(int color, int color2)
Returns the a color created by an average between two colors.
final int[] parts1 = getArgb(color);
final int[] parts2 = getArgb(color2);
for (int i = 0; i < parts1.length; i++) {
    parts1[i] = (int) ((float) (parts1[i] + parts2[i]) / 2f);
return getColorFromArgb(parts1);
intaverageBlendTwoColors(int c1, int c2)
Blend of color c1 and c2 by adding the components and dividing the results with 2.
int a1 = Color.alpha(c1);
int r1 =;
int g1 =;
int b1 =;
int a2 = Color.alpha(c2);
int r2 =;
int g2 =;
int b2 =;
intmultiplyBlendTwoColors(int c1, int c2)
Blend of color c1 and c2 by applying f(c1, c2) = c1 * c2 per channel.
double a1 = Color.alpha(c1) / ((double) CHANNEL_MAX);
double r1 = / ((double) CHANNEL_MAX);
double g1 = / ((double) CHANNEL_MAX);
double b1 = / ((double) CHANNEL_MAX);
double a2 = Color.alpha(c2) / ((double) CHANNEL_MAX);
double r2 = / ((double) CHANNEL_MAX);
double g2 = / ((double) CHANNEL_MAX);
double b2 = / ((double) CHANNEL_MAX);