An adapter class for presenting image data in a mediaLibImage
format, even if the data isn't stored that way. MediaLibAccessor
is meant to make the common case (ComponentRasters) and allow
them to be accelerated via medialib. Note that unlike RasterAccessor,
MediaLibAccessor does not work with all cases. In the event that
MediaLibAccessor can not deal with a give collection of Rasters,
findCompatibleTag will return the value MediaLibAccessor.TAG_INCOMPATIBLE.
OpImages that use MediaLibAccessor should be paired with RIF's
which check that findCompatibleTag returns a valid tag before
actually constructing the Mlib OpImage.
rect The rectangle of the raster that MediaLibAccessor addresses.
Constructor Summary
public
MediaLibAccessor(Raster raster, Rectangle rect, int formatTag, boolean preferPacked) Constructs a MediaLibAccessor object out of a Raster, Rectangle
and formatTag returned from MediaLibAccessor.findCompatibleTag().
In the case of binary data the copy mask bits of the formatTag
will be reset within the constructor according to whether the
data are in fact copied.
Method Summary
public void
clampDataArrays() Clamps data array values to a range that the underlying raster
can deal with.
public void
copyDataToRaster(int[] channelMap) Copies data back into the MediaLibAccessor's raster.
public static int
findCompatibleTag(Raster src) Returns the most efficient FormatTag that is compatible with
the destination raster and all source rasters.
The rectangle of the raster that MediaLibAccessor addresses.
Constructor Detail
MediaLibAccessor
public MediaLibAccessor(Raster raster, Rectangle rect, int formatTag, boolean preferPacked)(Code)
Constructs a MediaLibAccessor object out of a Raster, Rectangle
and formatTag returned from MediaLibAccessor.findCompatibleTag().
In the case of binary data the copy mask bits of the formatTag
will be reset within the constructor according to whether the
data are in fact copied. This cannot be easily determined before
the data are actually copied.
Clamps data array values to a range that the underlying raster
can deal with. For example, if the underlying raster stores
data as bytes, but the samples ares unpacked into integer arrays by
the RasterAccessor object for an operation, the operation will
need to call clampDataArrays() so that the data in the int
arrays is restricted to the range 0..255 before a setPixels()
call is made on the underlying raster. Note that some
operations (for example, lookup) can guarantee that their
results don't need clamping so they can call
RasterAccessor.copyDataToRaster() without first calling this
function.
copyDataToRaster
public void copyDataToRaster(int[] channelMap)(Code)
Copies data back into the MediaLibAccessor's raster. Note that
the data is casted from the intermediate data format to
the raster's format. If clamping is needed, the call
clampDataArrays() method needs to be called before
calling the copyDataToRaster() method.
findCompatibleTag
public static int findCompatibleTag(Raster src)(Code)
Returns the most efficient FormatTag that is compatible with
the destination raster and all source rasters.
Parameters: srcs - the source Raster; may be null. Parameters: dst - the destination Raster.
Returns the data type of the RasterAccessor object. Note that
this datatype is not necessarily the same data type as the
underlying raster.
getDoubleParameters
public double[] getDoubleParameters(int band, double params)(Code)
Returns parameters in the appropriate order if MediaLibAccessor
has reordered the bands or is attempting to make a
BandSequential image look like multiple PixelSequentialImages
getIntArrayParameters
public int[][] getIntArrayParameters(int band, int[][] params)(Code)
Returns parameters in the appropriate order if MediaLibAccessor
has reordered the bands or is attempting to make a
BandSequential image look like multiple PixelSequentialImages
getIntParameters
public int[] getIntParameters(int band, int params)(Code)
Returns parameters in the appropriate order if MediaLibAccessor
has reordered the bands or is attempting to make a
BandSequential image look like multiple PixelSequentialImages
getMediaLibDataType
public static int getMediaLibDataType(int formatTag)(Code)
Returns an array of mediaLibImages which represents the input raster.
An array is returned instead of a single mediaLibImage because
in some cases, an input Raster can't be represented by one
mediaLibImage (unless copying is done) but can be represented
by several mediaLibImages without copying.