Class RGBImageFilter
- All Implemented Interfaces:
ImageConsumer, Cloneable
- Direct Known Subclasses:
GrayFilter
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanThis 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 ColorModelTheColorModelwith which to replaceorigmodelwhen the user callssubstituteColorModel.protected ColorModelFields inherited from class ImageFilter
consumerModifier and TypeFieldDescriptionprotected ImageConsumerThe consumer of the particular image data stream for which this instance of the ImageFilter is filtering data.Fields inherited from interface ImageConsumer
COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHTModifier and TypeFieldDescriptionstatic final intThe pixels will be delivered in (multiples of) complete scanlines at a time.static final intThe image creation process was deliberately aborted.static final intAn error was encountered while producing the image.static final intThe pixels will be delivered in a random order.static final intThe image contain a single static image.static final intOne frame of the image is complete but there are more frames to be delivered.static final intThe pixels will be delivered in a single pass.static final intThe image is complete and there are no more pixels or frames to be delivered.static final intThe pixels will be delivered in top-down, left-to-right order. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionFilters an IndexColorModel object by running each entry in its color tables through the filterRGB function that RGBImageFilter subclasses must provide.abstract intfilterRGB(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.voidfilterRGBPixels(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.voidsetColorModel(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.voidsetPixels(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.voidsetPixels(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.voidsubstituteColorModel(ColorModel oldcm, ColorModel newcm) Registers two ColorModel objects for substitution.Methods inherited from class ImageFilter
clone, getFilterInstance, imageComplete, resendTopDownLeftRight, setDimensions, setHints, setPropertiesModifier and TypeMethodDescriptionclone()Clones this object.Returns a unique instance of an ImageFilter object which will actually perform the filtering for the specified ImageConsumer.voidimageComplete(int status) Filters the information provided in the imageComplete method of the ImageConsumer interface.voidResponds to a request for a TopDownLeftRight (TDLR) ordered resend of the pixel data from anImageConsumer.voidsetDimensions(int width, int height) Filters the information provided in the setDimensions method of the ImageConsumer interface.voidsetHints(int hints) Filters the information provided in the setHints method of the ImageConsumer interface.voidsetProperties(Hashtable<?, ?> props) Passes the properties from the source object along after adding a property indicating the stream of filters it has been run through.Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionbooleanIndicates whether some other object is "equal to" this one.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class<?> getClass()Returns the runtime class of thisObject.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Field Details
-
origmodel
-
newmodel
TheColorModelwith which to replaceorigmodelwhen the user callssubstituteColorModel. -
canFilterIndexColorModel
protected boolean canFilterIndexColorModelThis 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:
-
-
Constructor Details
-
RGBImageFilter
protected RGBImageFilter()Constructor for subclasses to call.
-
-
Method Details
-
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. 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
ImageProducerof theImagewhose 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:
setColorModelin interfaceImageConsumer- Overrides:
setColorModelin classImageFilter- Parameters:
model- the specifiedColorModel- See Also:
-
substituteColorModel
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
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
- Throws:
NullPointerException- ificmis null
-
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.- Parameters:
x- the X coordinate of the upper-left corner of the region of pixelsy- the Y coordinate of the upper-left corner of the region of pixelsw- the width of the region of pixelsh- the height of the region of pixelspixels- the array of pixelsoff- the offset into thepixelsarrayscansize- 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) 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
ImageProducerof theImagewhose 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:
setPixelsin interfaceImageConsumer- Overrides:
setPixelsin classImageFilter- Parameters:
x- the X coordinate of the upper-left corner of the area of pixels to be sety- the Y coordinate of the upper-left corner of the area of pixels to be setw- the width of the area of pixelsh- the height of the area of pixelsmodel- the specifiedColorModelpixels- the array of pixelsoff- the offset into thepixelsarrayscansize- the distance from one row of pixels to the next in thepixelsarray- See Also:
-
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.Note: This method is intended to be called by the
ImageProducerof theImagewhose 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:
setPixelsin interfaceImageConsumer- Overrides:
setPixelsin classImageFilter- Parameters:
x- the X coordinate of the upper-left corner of the area of pixels to be sety- the Y coordinate of the upper-left corner of the area of pixels to be setw- the width of the area of pixelsh- the height of the area of pixelsmodel- the specifiedColorModelpixels- the array of pixelsoff- the offset into thepixelsarrayscansize- the distance from one row of pixels to the next in thepixelsarray- See Also:
-
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.- Parameters:
x- the X coordinate of the pixely- the Y coordinate of the pixelrgb- the integer pixel representation in the default RGB color model- Returns:
- a filtered pixel in the default RGB color model.
- See Also:
-