Class RGBImageFilter
- All Implemented Interfaces:
-
ImageConsumer
,Cloneable
- Direct Known Subclasses:
GrayFilter
public abstract class RGBImageFilter extends ImageFilter
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));
}
}
Field Summary
Modifier and Type | Field | 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 ColorModel with which to replace origmodel when the user calls substituteColorModel . |
protected ColorModel |
origmodel |
Fields declared in class java.awt.image.ImageFilter
consumer
Fields declared in interface java.awt.image.ImageConsumer
COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHT
Constructor Summary
Modifier | Constructor | Description |
---|---|---|
protected |
Constructor for subclasses to call. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
IndexColorModel |
filterIndexColorModel |
Filters an IndexColorModel object by running each entry in its color tables through the filterRGB function that RGBImageFilter subclasses must provide. |
abstract int |
filterRGB |
Subclasses must specify a method to convert a single input pixel in the default RGB ColorModel to a single output pixel. |
void |
filterRGBPixels |
Filters a buffer of pixels in the default RGB ColorModel by passing them one by one through the filterRGB method. |
void |
setColorModel |
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 |
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 |
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 |
Registers two ColorModel objects for substitution. |
Methods declared in class java.awt.image.ImageFilter
clone, getFilterInstance, imageComplete, resendTopDownLeftRight, setDimensions, setHints, setProperties
Field Details
origmodel
protected ColorModel origmodel
newmodel
protected ColorModel newmodel
ColorModel
with which to replace origmodel
when the user calls substituteColorModel
.canFilterIndexColorModel
protected boolean canFilterIndexColorModel
Constructor Details
RGBImageFilter
protected RGBImageFilter()
Method Details
setColorModel
public void setColorModel(ColorModel model)
Note: This method is intended to be called by the ImageProducer
of the Image
whose pixels are being filtered. Developers using this class to filter pixels from an image should avoid calling this method directly since that operation could interfere with the filtering operation.
- Specified by:
-
setColorModel
in interfaceImageConsumer
- Overrides:
-
setColorModel
in classImageFilter
- Parameters:
-
model
- the specifiedColorModel
- See Also:
substituteColorModel
public void substituteColorModel(ColorModel oldcm, ColorModel newcm)
- Parameters:
-
oldcm
- the ColorModel object to be replaced on the fly -
newcm
- the ColorModel object to replace oldcm on the fly
filterIndexColorModel
public IndexColorModel filterIndexColorModel(IndexColorModel icm)
- Parameters:
-
icm
- the IndexColorModel object to be filtered - Returns:
- a new IndexColorModel representing the filtered colors
- Throws:
-
NullPointerException
- ificm
is null
filterRGBPixels
public void filterRGBPixels(int x, int y, int w, int h, int[] pixels, int off, int scansize)
- Parameters:
-
x
- the X coordinate of the upper-left corner of the region of pixels -
y
- the Y coordinate of the upper-left corner of the region of pixels -
w
- the width of the region of pixels -
h
- the height of the region of pixels -
pixels
- the array of pixels -
off
- the offset into thepixels
array -
scansize
- the distance from one row of pixels to the next in the array - See Also:
setPixels
public void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize)
Note: This method is intended to be called by the ImageProducer
of the Image
whose pixels are being filtered. Developers using this class to filter pixels from an image should avoid calling this method directly since that operation could interfere with the filtering operation.
- Specified by:
-
setPixels
in interfaceImageConsumer
- Overrides:
-
setPixels
in classImageFilter
- Parameters:
-
x
- the X coordinate of the upper-left corner of the area of pixels to be set -
y
- the Y coordinate of the upper-left corner of the area of pixels to be set -
w
- the width of the area of pixels -
h
- the height of the area of pixels -
model
- the specifiedColorModel
-
pixels
- the array of pixels -
off
- the offset into thepixels
array -
scansize
- the distance from one row of pixels to the next in thepixels
array - See Also:
setPixels
public void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int off, int scansize)
Note: This method is intended to be called by the ImageProducer
of the Image
whose pixels are being filtered. Developers using this class to filter pixels from an image should avoid calling this method directly since that operation could interfere with the filtering operation.
- Specified by:
-
setPixels
in interfaceImageConsumer
- Overrides:
-
setPixels
in classImageFilter
- Parameters:
-
x
- the X coordinate of the upper-left corner of the area of pixels to be set -
y
- the Y coordinate of the upper-left corner of the area of pixels to be set -
w
- the width of the area of pixels -
h
- the height of the area of pixels -
model
- the specifiedColorModel
-
pixels
- the array of pixels -
off
- the offset into thepixels
array -
scansize
- the distance from one row of pixels to the next in thepixels
array - See Also:
filterRGB
public abstract int filterRGB(int x, int y, int rgb)
- Parameters:
-
x
- the X coordinate of the pixel -
y
- the Y coordinate of the pixel -
rgb
- the integer pixel representation in the default RGB color model - Returns:
- a filtered pixel in the default RGB color model.
- See Also:
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/java/awt/image/RGBImageFilter.html