Class AreaOpImage
- All Implemented Interfaces:
RenderedImage,ImageImageN,PropertyChangeEmitter,PropertySource,WritablePropertySource
- Direct Known Subclasses:
BufferOpImage,ConvolveOpImage
The source and the destination images will occupy the same region of the plane. A given destination pixel (x, y) may be computed from the neighborhood of source pixels beginning at (x - leftPadding, y - topPadding) and extending to (x + rightPadding, y + bottomPadding) inclusive.
Since this operator needs a region around the source pixel in order to compute the destination pixel, the border destination pixels cannot be computed without any source extension. The source extension can be specified by supplying a BorderExtender that will define the pixel values of the source outside the actual source area.
If no extension is specified, the destination samples that cannot be computed will be written in the destination as zero. If the source image begins at pixel (minX, minY) and has width w and height h, the result of performing an area operation will be an image beginning at minX, minY, and having a width of w and a height of h, with the area being computed and written starting at (minX + leftPadding, minY + topPadding) and having width Math.max(w - leftPadding - rightPadding, 0) and height Math.max(h - topPadding - bottomPadding, 0).
A RenderingHints for ImageN.KEY_REPLACE_INDEX_COLOR_MODEL with the value of
Boolean.TRUE will automatically be added to the given configuration and passed up to the
superclass constructor so that area operations are performed on the pixel values instead of being performed on the
indices into the color map for those operations whose source(s) have an IndexColorModel. This addition
will only take place if a value for the ImageN.KEY_REPLACE_INDEX_COLOR_MODEL has not already been
provided by the user. Note that the configuration Map is cloned before the new hint is added to it.
Regarding the value for the ImageN.KEY_REPLACE_INDEX_COLOR_MODEL RenderingHints, the
operator itself can be smart based on the parameters, i.e. while the default value for the
ImageN.KEY_REPLACE_INDEX_COLOR_MODEL is Boolean.TRUE for operations that extend this class, in
some cases the operator could set the default.
- See Also:
-
Field Summary
Fields inherited from class OpImage
OP_COMPUTE_BOUND, OP_IO_BOUND, OP_NETWORK_BOUND -
Constructor Summary
ConstructorsConstructorDescriptionAreaOpImage(RenderedImage source, ImageLayout layout, Map configuration, boolean cobbleSources, BorderExtender extender, int leftPadding, int rightPadding, int topPadding, int bottomPadding) Constructs anAreaOpImage. -
Method Summary
Modifier and TypeMethodDescriptioncomputeTile(int tileX, int tileY) Computes a tile.Retrieve theBorderExtenderobject associated with this class instance.intReturns the number of pixels needed below the central pixel.intReturns the number of pixels needed to the left of the central pixel.intReturns the number of pixels needed to the right of the central pixel.intReturns the number of pixels needed above the central pixel.mapDestRect(Rectangle destRect, int sourceIndex) Returns a conservative estimate of the region of a specified source that is required in order to compute the pixels of a given destination rectangle.mapSourceRect(Rectangle sourceRect, int sourceIndex) Returns a conservative estimate of the destination region that can potentially be affected by the pixels of a rectangle of a given source.Methods inherited from class OpImage
cancelTiles, computesUniqueTiles, dispose, getExpandedNumBands, getOperationComputeType, getTile, getTileCache, getTileCacheMetric, getTileDependencies, getTileRecycler, getTiles, hasExtender, mapDestPoint, mapSourcePoint, prefetchTiles, queueTiles, setTileCacheMethods inherited from class PlanarImage
addPropertyChangeListener, addPropertyChangeListener, addSink, addTileComputationListener, copyData, copyData, copyExtendedData, createColorModel, createSnapshot, getAsBufferedImage, getAsBufferedImage, getBounds, getColorModel, getData, getData, getDefaultColorModel, getExtendedData, getGraphics, getHeight, getImageID, getMaxTileX, getMaxTileY, getMaxX, getMaxY, getMinTileX, getMinTileY, getMinX, getMinY, getNumBands, getNumSources, getNumXTiles, getNumYTiles, getProperty, getPropertyClass, getPropertyNames, getPropertyNames, getSampleModel, getSinks, getSource, getSourceImage, getSourceObject, getSources, getSplits, getTileComputationListeners, getTileFactory, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileIndices, getTileRect, getTiles, getTileWidth, getWidth, overlapsMultipleTiles, removeProperty, removePropertyChangeListener, removePropertyChangeListener, removeSink, removeSinks, removeTileComputationListener, setProperty, tileXToX, tileXToX, tileYToY, tileYToY, toString, wrapRenderedImage, XToTileX, XToTileX, YToTileY, YToTileY
-
Constructor Details
-
AreaOpImage
public AreaOpImage(RenderedImage source, ImageLayout layout, Map configuration, boolean cobbleSources, BorderExtender extender, int leftPadding, int rightPadding, int topPadding, int bottomPadding) Constructs anAreaOpImage. The layout variables are set in the standard way by theOpImageconstructor.Additional control over the image bounds, tile grid layout,
SampleModel, andColorModelmay be obtained by specifying anImageLayoutparameter. If the image bounds are specified but do not overlap the source bounds then anIllegalArgumentExceptionwill be thrown. This parameter will be passed to the superclass constructor unchanged.A
RenderingHintsforImageN.KEY_REPLACE_INDEX_COLOR_MODELwith the value ofBoolean.TRUEwill automatically be added to the givenconfigurationand passed up to the superclass constructor so that area operations are performed on the pixel values instead of being performed on the indices into the color map for those operations whose source(s) have anIndexColorModel. This addition will only take place if a value for theImageN.KEY_REPLACE_INDEX_COLOR_MODELhas not already been provided by the user. Note that theconfigurationMap is cloned before the new hint is added to it.- Parameters:
source- ARenderedImage.layout- AnImageLayoutcontaining the source dimensions before padding, and optionally containing the tile grid layout,SampleModel, andColorModel.configuration- Configurable attributes of the image including configuration variables indexed byRenderingHints.Keys and image properties indexed byStrings orCaselessStringKeys. This is simply forwarded to the superclass constructor.cobbleSources- Abooleanindicating whethercomputeRect()expects contiguous sources.extender- A BorderExtender, or null.leftPadding- The desired left padding.rightPadding- The desired right padding.topPadding- The desired top padding.bottomPadding- The desired bottom padding.- Throws:
IllegalArgumentException- ifsourceisnull.IllegalArgumentException- if the user-specified bounds do intersect the source bounds.
-
-
Method Details
-
getLeftPadding
public int getLeftPadding()Returns the number of pixels needed to the left of the central pixel.- Returns:
- The left padding factor.
-
getRightPadding
public int getRightPadding()Returns the number of pixels needed to the right of the central pixel.- Returns:
- The right padding factor.
-
getTopPadding
public int getTopPadding()Returns the number of pixels needed above the central pixel.- Returns:
- The top padding factor.
-
getBottomPadding
public int getBottomPadding()Returns the number of pixels needed below the central pixel.- Returns:
- The bottom padding factor.
-
getBorderExtender
Retrieve theBorderExtenderobject associated with this class instance. The object is returned by reference.- Returns:
- The associated
BorderExtenderobject ornull.
-
mapSourceRect
Returns a conservative estimate of the destination region that can potentially be affected by the pixels of a rectangle of a given source. The resultingRectangleis not clipped to the destination image bounds.- Specified by:
mapSourceRectin classOpImage- Parameters:
sourceRect- theRectanglein source coordinates.sourceIndex- the index of the source image.- Returns:
- a
Rectangleindicating the potentially affected destination region, ornullif the region is unknown. - Throws:
IllegalArgumentException- ifsourceIndexis negative or greater than the index of the last source.IllegalArgumentException- ifsourceRectisnull.
-
mapDestRect
Returns a conservative estimate of the region of a specified source that is required in order to compute the pixels of a given destination rectangle. The resultingRectangleis not clipped to the source image bounds.- Specified by:
mapDestRectin classOpImage- Parameters:
destRect- theRectanglein destination coordinates.sourceIndex- the index of the source image.- Returns:
- a
Rectangleindicating the required source region. - Throws:
IllegalArgumentException- ifsourceIndexis negative or greater than the index of the last source.IllegalArgumentException- ifdestRectisnull.
-
computeTile
Computes a tile. If source cobbling was requested at construction time, the source tile boundaries are overlayed onto the destination, cobbling is performed for areas that intersect multiple source tiles, andcomputeRect(Raster[], WritableRaster, Rectangle)is called for each of the resulting regions. Otherwise,computeRect(PlanarImage[], WritableRaster, Rectangle)is called once to compute the entire active area of the tile.The image bounds may be larger than the bounds of the source image. In this case, samples for which there are no no corresponding sources are set to zero.
- Overrides:
computeTilein classOpImage- Parameters:
tileX- The X index of the tile.tileY- The Y index of the tile.- Returns:
- The tile as a
Raster.
-