// allegedly the best method for rgb to grayscale conversion: // Z=0.2126×R+0.7152G+0.0722B static int rgbToLuminosity(int rgb) { int r = (rgb >> 16) & 0xFF; int g = (rgb >> 8) & 0xFF; int b = rgb & 0xFF; ret iround(r*0.2126+g*0.7152+b*0.0722); }