RGBImageFilter

The java.awt.image.RGBImageFilter class is an abstract subclass of java.awt.image.ImageFilter. It allows you to write image filters modify a single pixel at a time. It's used when each pixel's filtering is independent of the other pixels. On the other hand you would not use it for filters where the filtering depended on neighboring pixels such as a filter that averaged the surrounding pixels.

The only method you need to override in this class is filterRGB()

public abstract int filterRGB(int x, int y, int rgb) 
For performance reasons you may also wish to override filterRGBPixels() and set the canFilterIndexColorModel field to true. This field determines whether or not the filter depends on the position of the pixel. If it's true, then instead of filtering every pixel in the image, the limited number of entries is the image's color map are filtered instead. This is much faster. By default, it is assumed that the filter does depend on position and the value of the field is false.

public void filterRGBPixels(int x, int y, int w, int h, 
 int pixels[], int offset, int scan) 
The filterRGBPixels() method passes each pixel in the pixels array to the filterRGB() method one at a time. However you may be able to improve perforamnce in some cases by avoiding unnecessary method calls and filtering each pixel directly, especially if canFilterIndexColorModel is false.


Previous | Next | Top
Last Modified April 24, 1998
Copyright 1997, 1998 Elliotte Rusty Harold
elharo@metalab.unc.edu