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));
}
}
FilteredImageSource
, ImageFilter
, ColorModel#getRGBdefault
Modifier and Type | Field and Description |
---|---|
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
The |
protected ColorModel | origmodel
The |
Access | Constructor and Description |
---|---|
protected |
Modifier and Type | Method and Description |
---|---|
public IndexColorModel | Returns: a new IndexColorModel representing the filtered colorsthe IndexColorModel object to be filtered icm)Filters an IndexColorModel object by running each entry in its color tables through the filterRGB function that RGBImageFilter subclasses must provide. |
public abstract int | Returns: a filtered pixel in the default RGB color model.the X coordinate of the pixel x, int the Y coordinate of the pixel y, int the integer pixel representation in the default RGB
color model rgb)Subclasses must specify a method to convert a single input pixel in the default RGB ColorModel to a single output pixel. |
public void | filterRGBPixels(int
the X coordinate of the upper-left corner of the region
of pixels x, int the Y coordinate of the upper-left corner of the region
of pixels y, int the width of the region of pixels w, int the height of the region of pixels h, int[] the array of pixels pixels, int the offset into the off, int pixels arraythe distance from one row of pixels to the next
in the array scansize)Filters a buffer of pixels in the default RGB ColorModel by passing them one by one through the filterRGB method. |
public void | setColorModel(ColorModel
the specified model)ColorModel Overrides java. Implements java. 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. |
public void | setPixels(int
the X coordinate of the upper-left corner of the
area of pixels to be set x, int the Y coordinate of the upper-left corner of the
area of pixels to be set y, int the width of the area of pixels w, int the height of the area of pixels h, ColorModel the specified model, byte[] ColorModel the array of pixels pixels, int the offset into the off, int pixels arraythe distance from one row of pixels to the next in
the scansize)pixels arrayOverrides java. Implements java. If the ColorModel object is the same one that has already been converted, then simply passes the pixels through with the converted ColorModel. |
public void | setPixels(int
the X coordinate of the upper-left corner of the
area of pixels to be set x, int the Y coordinate of the upper-left corner of the
area of pixels to be set y, int the width of the area of pixels w, int the height of the area of pixels h, ColorModel the specified model, int[] ColorModel the array of pixels pixels, int the offset into the off, int pixels arraythe distance from one row of pixels to the next in
the scansize)pixels arrayOverrides java. Implements java. 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. |
public void | substituteColorModel(ColorModel
the ColorModel object to be replaced on the fly oldcm, ColorModel the ColorModel object to replace oldcm on the fly newcm)Registers two ColorModel objects for substitution. |
canFilterIndexColorModel | back to 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. 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.
|
newmodel | back to summary |
---|---|
protected ColorModel newmodel The |
origmodel | back to summary |
---|---|
protected ColorModel origmodel The |
RGBImageFilter | back to summary |
---|---|
protected RGBImageFilter() Constructor for subclasses to call. |
filterIndexColorModel | back to summary |
---|---|
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.
|
filterRGB | back to summary |
---|---|
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.
|
filterRGBPixels | back to summary |
---|---|
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.
|
setColorModel | back to summary |
---|---|
public void setColorModel(ColorModel model) Overrides java. Implements java. 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. If the ColorModel is not an IndexColorModel or is null, this method overrides the default ColorModel used by the ImageProducer and specifies the default RGB ColorModel instead. Note This method is intended to be called by the
|
setPixels | back to summary |
---|---|
public void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize) Overrides java. Implements java. 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. Note This method is intended to be called by the
|
setPixels | back to summary |
---|---|
public void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int off, int scansize) Overrides java. Implements java. 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. Note This method is intended to be called by the
|
substituteColorModel | back to summary |
---|---|
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).
|