return (int) (p * (0.299 * ((0xff0000 & rgb) >> 16) + 0.587 * ((0xff00 & rgb) >> 8) + 0.114 * (0xff & rgb)));
int alpha = 0xff000000 & rgb; int red = (0xff0000 & rgb) >> 16; int green = (0xff00 & rgb) >> 8; int blue = (0xff & rgb); int gray = (int) ((0.299 * red + 0.587 * green + 0.114 * blue) * p); if (b) gray = Math.min(gray + 128, 255); return gray | gray << 8 | gray << 16 | alpha ;
  public int filterRGB(int x, int y, int rgb)    {    return (int) (p * (0.299 * ((0xff0000 & rgb) >> 16)		       + 0.587 * ((0xff00 & rgb) >> 8) + 0.114 * (0xff & rgb)));    }