Here you can find the source of createGrayedImage(Image i, final boolean b, final int p)
public static Image createGrayedImage(Image i, final boolean b, final int p)
//package com.java2s; import java.awt.Image; import java.awt.Toolkit; import java.awt.image.FilteredImageSource; import java.awt.image.ImageFilter; import java.awt.image.ImageProducer; import javax.swing.GrayFilter; public class Main { public static Image createGrayedImage(Image i, final boolean b, final int p) { ImageFilter filter = new GrayFilter(b, p); ImageProducer prod = new FilteredImageSource(i.getSource(), filter); Image grayImage = Toolkit.getDefaultToolkit().createImage(prod); return grayImage; }/*from w w w. java 2 s . c o m*/ }