javax.media.jai
Class ColormapOpImage

java.lang.Object
  |
  +--javax.media.jai.PlanarImage
        |
        +--javax.media.jai.OpImage
              |
              +--javax.media.jai.PointOpImage
                    |
                    +--javax.media.jai.ColormapOpImage
All Implemented Interfaces:
ImageJAI, PropertyChangeEmitter, PropertySource, RenderedImage, WritablePropertySource

public abstract class ColormapOpImage
extends PointOpImage

A class to be used to implement an operation which may conditionally be accelerated by transforming the colormap of the source image instead of its data. An instance of this class will represent the destination of a single-source point operation which may be effected by a simple transformation of the source image colormap if the ColorModels of the source and destination images are both instances of IndexColorModel. A subclass may take advantage of this capability merely by implementing transformColormap() and invoking initializeColormapOperation() as the last statement of its constructor. If the ColorModels are not IndexColorModels, the behavior is the same as if the superclass PointOpImage had been extended directly.

The default behavior for a ColormapOpImage is to do the transform only on the color map in order to accelerate processing when the source and destination images are all color-indexed. However, in some situations it may be desirable to transform the pixel (index) data directly instead of transforming the colormap. To suppress the acceleration, a mapping of the key JAI.KEY_TRANSFORM_ON_COLORMAP with value Boolean.FALSE should be added to the configuration map (or the RenderingHints provided to the create methods in the class JAI) supplied to the corresponding operation when it is created.

Transforming on the pixel (index) data is only meaningful when the transform maps all the possible index values of the source image into the index value set of the destination image. Otherwise, it may generate pixel (index) values without color definitions, and cause problems when computing the color components from pixel values. In addition, the colormaps should be ordered in a useful way for the transform in question, e.g. a smooth grayscale.

Since:
JAI 1.1
See Also:
IndexColorModel, PointOpImage

Fields inherited from class javax.media.jai.OpImage
cache, cobbleSources, OP_COMPUTE_BOUND, OP_IO_BOUND, OP_NETWORK_BOUND, tileCacheMetric, tileRecycler
 
Fields inherited from class javax.media.jai.PlanarImage
colorModel, eventManager, height, minX, minY, properties, sampleModel, tileFactory, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, width
 
Constructor Summary
ColormapOpImage(RenderedImage source, ImageLayout layout, Map configuration, boolean cobbleSources)
          Constructs a ColormapOpImage with one source image.
 
Method Summary
protected  void initializeColormapOperation()
          Method to be invoked as the last statement of a subclass constructor.
protected  boolean isColormapOperation()
          Whether the operation is performed on the colormap directly.
protected abstract  void transformColormap(byte[][] colormap)
          Transform the colormap according to the specific operation.
 
Methods inherited from class javax.media.jai.PointOpImage
computeTile, dispose, mapDestRect, mapSourceRect, permitInPlaceOperation
 
Methods inherited from class javax.media.jai.OpImage
addTileToCache, cancelTiles, computeRect, computeRect, computesUniqueTiles, createTile, getExpandedNumBands, getFormatTags, getOperationComputeType, getTile, getTileCache, getTileCacheMetric, getTileDependencies, getTileFromCache, getTileRecycler, getTiles, hasExtender, mapDestPoint, mapSourcePoint, prefetchTiles, queueTiles, recycleTile, setTileCache, vectorize, vectorize, vectorize
 
Methods inherited from class javax.media.jai.PlanarImage
addPropertyChangeListener, addPropertyChangeListener, addSink, addSink, addSource, addTileComputationListener, copyData, copyData, copyExtendedData, createColorModel, createSnapshot, createWritableRaster, finalize, getAsBufferedImage, getAsBufferedImage, getBounds, getColorModel, getData, getData, getDefaultColorModel, getExtendedData, getGraphics, getHeight, getImageID, getMaxTileX, getMaxTileY, getMaxX, getMaxY, getMinTileX, getMinTileY, getMinX, getMinY, getNumBands, getNumSources, getNumXTiles, getNumYTiles, getProperties, 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, removeSink, removeSinks, removeSource, removeSources, removeTileComputationListener, setImageLayout, setProperties, setProperty, setSource, setSources, tileXToX, tileXToX, tileYToY, tileYToY, toString, wrapRenderedImage, XToTileX, XToTileX, YToTileY, YToTileY
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ColormapOpImage

public ColormapOpImage(RenderedImage source,
                       ImageLayout layout,
                       Map configuration,
                       boolean cobbleSources)
Constructs a ColormapOpImage with one source image. The parameters are forwarded unmodified to the equivalent superclass constructor.
Parameters:
layout - The layout parameters of the destination image.
source - The source image.
configuration - Configurable attributes of the image including configuration variables indexed by RenderingHints.Keys and image properties indexed by Strings or CaselessStringKeys. This is simply forwarded to the superclass constructor.
cobbleSources - Indicates whether computeRect() expects contiguous sources.
Throws:
IllegalArgumentException - if source is null.
Method Detail

isColormapOperation

protected final boolean isColormapOperation()
Whether the operation is performed on the colormap directly.
Overrides:
isColormapOperation in class PointOpImage

initializeColormapOperation

protected final void initializeColormapOperation()
Method to be invoked as the last statement of a subclass constructor. The colormap acceleration flag is set appropriately and if true a new ColorModel is calculated by transforming the source colormap. This method must be invoked in the subclass constructor as it calls transformColormap() which is abstract and therefore requires that the implementing class be constructed before it may be invoked.

transformColormap

protected abstract void transformColormap(byte[][] colormap)
Transform the colormap according to the specific operation. The modification is done in place so that the parameter array will be modified. The format of the parameter array is byte[3][] wherein colormap[0], colormap[1], and colormap[2] represent the red, green, and blue colormaps, respectively.