home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 25 / nopv25.iso / 040A / IBUTTON.ZIP / ImageButton / Source / GrayFilter.java < prev    next >
Encoding:
Java Source  |  1997-06-03  |  455 b   |  20 lines

  1.  
  2. package jlouie.beans;
  3.  
  4. import java.awt.*;
  5. import java.awt.image.*;
  6.  
  7. public class GrayFilter extends RGBImageFilter {
  8.    public GrayFilter() {
  9.       canFilterIndexColorModel= true;
  10.    }
  11.    
  12.    public int filterRGB(int x, int y, int rgb) {
  13.       int a= rgb & 0xff000000;
  14.       int r= ((rgb & 0xff0000)+0xff0000)/2;
  15.       int g= ((rgb & 0x00ff00)+0x00ff00)/2;
  16.       int b= ((rgb & 0x0000ff)+0x0000ff)/2;
  17.       return a | r |g | b;
  18.    }
  19. }
  20.