// This example is from the book _Java AWT Reference_ by John Zukowski. // Written by John Zukowski. Copyright (c) 1997 O'Reilly & Associates. // You may study, use, modify, and distribute this example for any purpose. // This example is provided WITHOUT WARRANTY either expressed or import java.awt.*; import java.awt.image.*; public class BlurFilter extends ImageFilter { private int savedWidth, savedHeight, savedPixels[]; private static ColorModel defaultCM = ColorModel.getRGBdefault(); public void setDimensions (int width, int height) { savedWidth=width; savedHeight=height; savedPixels=new int [width*height]; consumer.setDimensions (width, height); } public void setColorModel (ColorModel model) { // Change color model to model you are generating consumer.setColorModel (defaultCM); } public void setHints (int hintflags) { // Set new hints, but preserve SINGLEFRAME setting consumer.setHints (TOPDOWNLEFTRIGHT | COMPLETESCANLINES | SINGLEPASS | (hintflags & SINGLEFRAME)); } private void setThePixels (int x, int y, int width, int height, ColorModel cm, Object pixels, int offset, int scansize) { int sourceOffset = offset; int destinationOffset = y * savedWidth + x; boolean bytearray = (pixels instanceof byte[]); for (int yy=0;yy-->