Here you can find the source of applyFilter(BufferedImage img, ImageFilter filter)
public static void applyFilter(BufferedImage img, ImageFilter filter)
//package com.java2s; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.awt.image.FilteredImageSource; import java.awt.image.ImageFilter; public class Main { public static void applyFilter(BufferedImage img, ImageFilter filter) { FilteredImageSource src = new FilteredImageSource(img.getSource(), filter); Image fImg = Toolkit.getDefaultToolkit().createImage(src); Graphics2D g = img.createGraphics(); g.drawImage(fImg, 0, 0, null, null); g.dispose();/*from w w w . j a v a2 s . c o m*/ } }