Here you can find the source of getAverageColour(List
public static int getAverageColour(List<Integer> colours)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static int getAverageColour(List<Integer> colours) { int r = 0; int g = 0; int b = 0; int a = 0; int col;// w w w.ja va 2 s . c o m int count = colours.size(); for (int i = 0; i < count; i++) { col = colours.get(i); r += red(col); g += green(col); b += blue(col); a += alpha(col); } return compose(r / count, g / count, b / count, a / count); } public static int red(int c) { return (c >> 16) & 0xFF; } public static int green(int c) { return (c >> 8) & 0xFF; } public static int blue(int c) { return (c) & 0xFF; } public static int alpha(int c) { return (c >> 24) & 0xFF; } public static int compose(int r, int g, int b, int a) { int rgb = a; rgb = (rgb << 8) + r; rgb = (rgb << 8) + g; rgb = (rgb << 8) + b; return rgb; } public static int compose(int[] col) { int r = col[0]; int g = col[1]; int b = col[2]; int a = col.length > 3 ? col[3] : 255; return compose(r, g, b, a); } }