当前页面:
在线文档首页 >
JDK 5 Documentation v1.2.2, Java 2 SDK 英文文档
Java(TM) 2 Platform, Standard Edition, v1.2.2 API Specification: Class RGBImageFilter - JDK 5 Documentation v1.2.2, Java 2 SDK 英文文档
java.awt.image
Class RGBImageFilter
java.lang.Object
|
+--java.awt.image.ImageFilter
|
+--java.awt.image.RGBImageFilter
- Direct Known Subclasses:
- GrayFilter
- public abstract class RGBImageFilter
- extends ImageFilter
This class provides an easy way to create an ImageFilter which modifies
the pixels of an image in the default RGB ColorModel. It is meant to
be used in conjunction with a FilteredImageSource object to produce
filtered versions of existing images. It is an abstract class that
provides the calls needed to channel all of the pixel data through a
single method which converts pixels one at a time in the default RGB
ColorModel regardless of the ColorModel being used by the ImageProducer.
The only method which needs to be defined to create a useable image
filter is the filterRGB method. Here is an example of a definition
of a filter which swaps the red and blue components of an image:
class RedBlueSwapFilter extends RGBImageFilter {
public RedBlueSwapFilter() {
// The filter's operation does not depend on the
// pixel's location, so IndexColorModels can be
// filtered directly.
canFilterIndexColorModel = true;
}
public int filterRGB(int x, int y, int rgb) {
return ((rgb & 0xff00ff00)
| ((rgb & 0xff0000) >> 16)
| ((rgb & 0xff) << 16));
}
}
- See Also:
FilteredImageSource
,
ImageFilter
,
ColorModel.getRGBdefault()
Field Summary |
protected boolean |
canFilterIndexColorModel
This boolean indicates whether or not it is acceptable to apply
the color filtering of the filterRGB method to the color table
entries of an IndexColorModel object in lieu of pixel by pixel
filtering. |
protected ColorModel |
newmodel
|
protected ColorModel |
origmodel
|
Method Summary |
IndexColorModel |
filterIndexColorModel(IndexColorModel icm)
Filters an IndexColorModel object by running each entry in its
color tables through the filterRGB function that RGBImageFilter
subclasses must provide. |
abstract int |
filterRGB(int x,
int y,
int rgb)
Subclasses must specify a method to convert a single input pixel
in the default RGB ColorModel to a single output pixel. |
void |
filterRGBPixels(int x,
int y,
int w,
int h,
int[] pixels,
int off,
int scansize)
Filters a buffer of pixels in the default RGB ColorModel by passing
them one by one through the filterRGB method. |
void |
setColorModel(ColorModel model)
If the ColorModel is an IndexColorModel, and the subclass has
set the canFilterIndexColorModel flag to true, we substitute
a filtered version of the color model here and wherever
that original ColorModel object appears in the setPixels methods. |
void |
setPixels(int x,
int y,
int w,
int h,
ColorModel model,
byte[] pixels,
int off,
int scansize)
If the ColorModel object is the same one that has already
been converted, then simply passes the pixels through with the
converted ColorModel. |
void |
setPixels(int x,
int y,
int w,
int h,
ColorModel model,
int[] pixels,
int off,
int scansize)
If the ColorModel object is the same one that has already
been converted, then simply passes the pixels through with the
converted ColorModel, otherwise converts the buffer of integer
pixels to the default RGB ColorModel and passes the converted
buffer to the filterRGBPixels method to be converted one by one. |
void |
substituteColorModel(ColorModel oldcm,
ColorModel newcm)
Registers two ColorModel objects for substitution. |
origmodel
protected ColorModel origmodel
newmodel
protected ColorModel newmodel
canFilterIndexColorModel
protected boolean canFilterIndexColorModel
- This boolean indicates whether or not it is acceptable to apply
the color filtering of the filterRGB method to the color table
entries of an IndexColorModel object in lieu of pixel by pixel
filtering. Subclasses should set this variable to true in their
constructor if their filterRGB method does not depend on the
coordinate of the pixel being filtered.
- See Also:
substituteColorModel(java.awt.image.ColorModel, java.awt.image.ColorModel)
,
filterRGB(int, int, int)
,
IndexColorModel
RGBImageFilter
public RGBImageFilter()
setColorModel
public void setColorModel(ColorModel model)
- If the ColorModel is an IndexColorModel, and the subclass has
set the canFilterIndexColorModel flag to true, we substitute
a filtered version of the color model here and wherever
that original ColorModel object appears in the setPixels methods. Otherwise
overrides the default ColorModel used by the ImageProducer and
specifies the default RGB ColorModel instead.
- Overrides:
- setColorModel in class ImageFilter
- See Also:
ImageConsumer
,
ColorModel.getRGBdefault()
substituteColorModel
public void substituteColorModel(ColorModel oldcm,
ColorModel newcm)
- Registers two ColorModel objects for substitution. If the oldcm
is encountered during any of the setPixels methods, the newcm
is substituted and the pixels passed through
untouched (but with the new ColorModel object).
- Parameters:
oldcm
- the ColorModel object to be replaced on the flynewcm
- the ColorModel object to replace oldcm on the fly
filterIndexColorModel
public IndexColorModel filterIndexColorModel(IndexColorModel icm)
- Filters an IndexColorModel object by running each entry in its
color tables through the filterRGB function that RGBImageFilter
subclasses must provide. Uses coordinates of -1 to indicate that
a color table entry is being filtered rather than an actual
pixel value.
- Parameters:
icm
- the IndexColorModel object to be filtered- Returns:
- a new IndexColorModel representing the filtered colors
filterRGBPixels
public void filterRGBPixels(int x,
int y,
int w,
int h,
int[] pixels,
int off,
int scansize)
- Filters a buffer of pixels in the default RGB ColorModel by passing
them one by one through the filterRGB method.
- See Also:
ColorModel.getRGBdefault()
,
filterRGB(int, int, int)
setPixels
public void setPixels(int x,
int y,
int w,
int h,
ColorModel model,
byte[] pixels,
int off,
int scansize)
- If the ColorModel object is the same one that has already
been converted, then simply passes the pixels through with the
converted ColorModel. Otherwise converts the buffer of byte
pixels to the default RGB ColorModel and passes the converted
buffer to the filterRGBPixels method to be converted one by one.
- Overrides:
- setPixels in class ImageFilter
- See Also:
ColorModel.getRGBdefault()
,
filterRGBPixels(int, int, int, int, int[], int, int)
setPixels
public void setPixels(int x,
int y,
int w,
int h,
ColorModel model,
int[] pixels,
int off,
int scansize)
- If the ColorModel object is the same one that has already
been converted, then simply passes the pixels through with the
converted ColorModel, otherwise converts the buffer of integer
pixels to the default RGB ColorModel and passes the converted
buffer to the filterRGBPixels method to be converted one by one.
Converts a buffer of integer pixels to the default RGB ColorModel
and passes the converted buffer to the filterRGBPixels method.
- Overrides:
- setPixels in class ImageFilter
- See Also:
ColorModel.getRGBdefault()
,
filterRGBPixels(int, int, int, int, int[], int, int)
filterRGB
public abstract int filterRGB(int x,
int y,
int rgb)
- Subclasses must specify a method to convert a single input pixel
in the default RGB ColorModel to a single output pixel.
- See Also:
ColorModel.getRGBdefault()
,
filterRGBPixels(int, int, int, int, int[], int, int)
Submit a bug or feature
Java, Java 2D, and JDBC are a trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.