public static int luma(int color)
    {
        int red = (color & RED_MASK) >> 16; 
        int green = (color & GREEN_MASK) >> 8;
        int blue = (color & BLUE_MASK);

        double y = 0.3*red + 0.59*green + 0.11*blue;

        return (int)y;
    }