FileDocCategorySizeDatePackage
GrayscaleImageFilter.javaAPI DocExample777Thu Apr 05 01:39:46 BST 2001None

GrayscaleImageFilter

public class GrayscaleImageFilter extends RGBImageFilter

Fields Summary
Constructors Summary
public GrayscaleImageFilter()

    canFilterIndexColorModel = true;
  
Methods Summary
public intfilterRGB(int x, int y, int pixel)


    // Get the average RGB intensity
    int red = (pixel & 0x00ff0000) >> 16;
    int green = (pixel & 0x0000ff00) >> 8;
    int blue = pixel & 0x000000ff;

    int luma = (int) (0.299 * red + 0.587 * green + 0.114 * blue);

    // Return the luma value as the value for each RGB component
    // Note: Alpha (transparency) is always set to max (not transparent)
    return (0xff << 24) | (luma << 16) | (luma << 8) | luma;