java.lang.Object
|
+----java.awt.image.ImageFilter
|
+----java.awt.image.RGBImageFilter
该类提供创建一个 ImageFilter 的简单方式,它修改缺省 RGB ColorModel 中的图像像素。即使用它来连接一个 FilteredImageSource 对象以生成现存图像的过滤版本。它是一个抽象类,无论 ImageProducer 正在使用何种 ColorModel,此抽象类通过一个方法提供传输所有像素数据所需的调用,此方法在缺省 RGB ColorModel 中一次转换一个像素。创建一个可用图像过滤器所需定义的唯一方法是 filterRGB 方法。此即交换一个图像红蓝组件的过滤器的定义的示例:
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)); } }
protected ColorModel origmodelnewmodel
protected ColorModel newmodelcanFilterIndexColorModel
protected boolean canFilterIndexColorModel
public RGBImageFilter()
public void setColorModel(ColorModel model)
public void substituteColorModel(ColorModel oldcm,
ColorModel newcm)
public IndexColorModel filterIndexColorModel(IndexColorModel icm)
public void filterRGBPixels(int x,
int y,
int w,
int h,
int pixels[],
int off,
int scansize)
public void setPixels(int x,
int y,
int w,
int h,
ColorModel model,
byte pixels[],
int off,
int scansize)
public void setPixels(int x,
int y,
int w,
int h,
ColorModel model,
int pixels[],
int off,
int scansize)
public abstract int filterRGB(int x,
int y,
int rgb)