java.awt.image
Class RGBImageFilter

java.lang.Object
  extended by java.awt.image.ImageFilter
      extended by java.awt.image.RGBImageFilter
All Implemented Interfaces:
ImageConsumer, Cloneable
Direct Known Subclasses:
GrayFilter

public abstract class RGBImageFilter
extends ImageFilter

A filter designed to filter images in the default RGBColorModel regardless of the ImageProducer's ColorModel.


Field Summary
protected  boolean canFilterIndexColorModel
          Specifies whether to apply the filter to the index entries of the IndexColorModel.
protected  ColorModel newmodel
           
protected  ColorModel origmodel
           
 
Fields inherited from class java.awt.image.ImageFilter
consumer
 
Fields inherited from interface java.awt.image.ImageConsumer
COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHT
 
Constructor Summary
RGBImageFilter()
          Construct new RGBImageFilter.
 
Method Summary
 IndexColorModel filterIndexColorModel(IndexColorModel icm)
          Filters an IndexColorModel through the filterRGB function.
abstract  int filterRGB(int x, int y, int rgb)
          Filters a single pixel from the default ColorModel.
 void filterRGBPixels(int x, int y, int w, int h, int[] pixels, int offset, int scansize)
          This functions filters a set of RGB pixels through filterRGB.
 void setColorModel(ColorModel model)
          Sets the ColorModel used to filter with.
 void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int offset, int scansize)
          If the ColorModel is the same ColorModel which as already converted then it converts it the converted ColorModel.
 void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int offset, int scansize)
          This function delivers a rectangle of pixels where any pixel(m,n) is stored in the array as an int at index (n * scansize + m + offset).
 void substituteColorModel(ColorModel oldcm, ColorModel newcm)
          Registers a new ColorModel to subsitute for the old ColorModel when setPixels encounters the a pixel with the old ColorModel.
 
Methods inherited from class java.awt.image.ImageFilter
clone, getFilterInstance, imageComplete, resendTopDownLeftRight, setDimensions, setHints, setProperties
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

origmodel

protected ColorModel origmodel

newmodel

protected ColorModel newmodel

canFilterIndexColorModel

protected boolean canFilterIndexColorModel
Specifies whether to apply the filter to the index entries of the IndexColorModel. Subclasses should set this to true if the filter does not depend on the pixel's coordinate.

Constructor Detail

RGBImageFilter

public RGBImageFilter()
Construct new RGBImageFilter.

Method Detail

setColorModel

public void setColorModel(ColorModel model)
Sets the ColorModel used to filter with. If the specified ColorModel is IndexColorModel and canFilterIndexColorModel is true, we subsitute the ColorModel for a filtered one here and in setPixels whenever the original one appears. Otherwise overrides the default ColorModel of ImageProducer and specifies the default RGBColorModel

Specified by:
setColorModel in interface ImageConsumer
Overrides:
setColorModel in class ImageFilter
Parameters:
model - the color model to be used most often by setPixels
See Also:
ColorModel

substituteColorModel

public void substituteColorModel(ColorModel oldcm,
                                 ColorModel newcm)
Registers a new ColorModel to subsitute for the old ColorModel when setPixels encounters the a pixel with the old ColorModel. The pixel remains unchanged except for a new ColorModel.

Parameters:
oldcm - the old ColorModel
newcm - the new ColorModel

filterIndexColorModel

public IndexColorModel filterIndexColorModel(IndexColorModel icm)
Filters an IndexColorModel through the filterRGB function. Uses coordinates of -1 to indicate its filtering an index and not a pixel.

Parameters:
icm - an IndexColorModel to filter

filterRGBPixels

public void filterRGBPixels(int x,
                            int y,
                            int w,
                            int h,
                            int[] pixels,
                            int offset,
                            int scansize)
This functions filters a set of RGB pixels through filterRGB.

Parameters:
x - the x coordinate of the rectangle
y - the y coordinate of the rectangle
w - the width of the rectangle
h - the height of the rectangle
pixels - the array of pixel values
offset - the index of the first pixels in the pixels array
scansize - the width to use in extracting pixels from the pixels array

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      ColorModel model,
                      byte[] pixels,
                      int offset,
                      int scansize)
If the ColorModel is the same ColorModel which as already converted then it converts it the converted ColorModel. Otherwise it passes the array of pixels through filterRGBpixels.

Specified by:
setPixels in interface ImageConsumer
Overrides:
setPixels in class ImageFilter
Parameters:
x - the x coordinate of the rectangle
y - the y coordinate of the rectangle
w - the width of the rectangle
h - the height of the rectangle
model - the ColorModel used to translate the pixels
pixels - the array of pixel values
offset - the index of the first pixels in the pixels array
scansize - the width to use in extracting pixels from the pixels array

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      ColorModel model,
                      int[] pixels,
                      int offset,
                      int scansize)
This function delivers a rectangle of pixels where any pixel(m,n) is stored in the array as an int at index (n * scansize + m + offset).

Specified by:
setPixels in interface ImageConsumer
Overrides:
setPixels in class ImageFilter
Parameters:
x - the x coordinate of the rectangle
y - the y coordinate of the rectangle
w - the width of the rectangle
h - the height of the rectangle
model - the ColorModel used to translate the pixels
pixels - the array of pixel values
offset - the index of the first pixels in the pixels array
scansize - the width to use in extracting pixels from the pixels array

filterRGB

public abstract int filterRGB(int x,
                              int y,
                              int rgb)
Filters a single pixel from the default ColorModel.

Parameters:
x - x-coordinate
y - y-coordinate
rgb - color