javax.media.jai
Class RasterFormatTag

java.lang.Object
  |
  +--javax.media.jai.RasterFormatTag

public final class RasterFormatTag
extends Object

This class encapsulates the information needed for RasterAccessor to understand how a Raster is laid out. It's designed so that one RasterFormatTag can be constructed per source and that RasterFormatTag can cache information that the RasterAccessor would otherwise have to extract from the Raster each time it's constructed (generally each time OpImage.computeRect() is called.) Additionally, it can cache various arrays (i.e. bankIndices[] and bandOffsets[]) that would otherwise be cloned everytime they were requested. Because of the way SampleModel.createCompatibleSampleModel() is designed not all fields of a particular SampleModel will match those of the SampleModel returned by SampleModel.createCompatibleSampleModel(). Values like pixelStride and numBands won't change, but values like bankIndicies[] and bandOffsets[] might if the underlying Raster is not pixelSequential. Rasters which are pixelSequential meet the following conditions 1) The SampleModel is a ComponentSampleModel. 2) The pixelStride is equal to the number of bands. 3) All the bankIndices[] are equal. 4) All the bandOffsets[] values are less than pixelStride 5) No two bandOffsets[] values are equal. For that reason, RasterFormatTags representing non pixelSequential rasters don't attempt to cache the bandOffsets[] or bankIndices[]. For such rasters, this information should be taken directly from the raster itself. Note that any RasterFormatTag that will cause data to be copied from the Raster will be pixelSequential as that is the format in which data is returned from Raster.getPixels() returns.


Constructor Summary
RasterFormatTag(SampleModel sampleModel, int formatTagID)
          Constructs a RasterFormatTag given a sampleModel and a formatTagID.
 
Method Summary
 int[] getBandOffsets()
          Returns the bandOffsets for the Raster if isPixelSequential() is true.
 int[] getBankIndices()
          Returns the bankIndices for the Raster if isPixelSequential() is true.
 int getFormatTagID()
          Returns the FormatTagID used to construct this RasterFormatTag.
 int getNumBands()
          Returns the number of bands in the underlying Raster
 int getPixelStride()
          Returns the pixelStride of the underlying Raster
 boolean isPixelSequential()
          Returns whether or not the SampleModel represented by the RasterFormatTag is PixelSequential.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RasterFormatTag

public RasterFormatTag(SampleModel sampleModel,
                       int formatTagID)
Constructs a RasterFormatTag given a sampleModel and a formatTagID. Generally, this constructor is called by RasterAccessor.findCompatibleTags(RenderedImage[] srcs, RenderedImage dst) and it takes care of setting the values correctly. In special cases, OpImages need to construct a RasterFormatTag without creating a RenderedImage. In this case a RasterFormatTag can be created using a formatTagID returned from RasterAccessor.findCompatibleTag(SampleModel[] srcs, SampleModel dst) and a sampleModel that was either passed in to the findCompatibleTag() call or one that was created using createCompatibleSampleModel() on one of the passed in SampleModels. Attempting to use arbitrary SampleModels with arbitrary formatTagIDs has undefined results. param sampleModel A SampleModel for the RasterFormagTag param formatTagID An int to indicate format tag id
Method Detail

isPixelSequential

public final boolean isPixelSequential()
Returns whether or not the SampleModel represented by the RasterFormatTag is PixelSequential. Note that RasterFormatTag's that indicate data should be copied out of the Raster by the RasterAccessor will always return true for isPixelSequential(). RasterFormatTags that indicate no copying is needed will only return true, if 1) The SampleModel is a ComponentSampleModel. 2) The pixelStride is equal to the number of bands. 3) All the bankIndices[] are equal. 4) All the bandOffsets[] values are less than pixelStride 5) No two bandOffset values are equal.

getFormatTagID

public final int getFormatTagID()
Returns the FormatTagID used to construct this RasterFormatTag. Valid values are defined in javax.media.jai.RasterAccessor.

getBankIndices

public final int[] getBankIndices()
Returns the bankIndices for the Raster if isPixelSequential() is true. Returns null otherwise. In the COPIED case, the bankIndices will all be 0.

getNumBands

public final int getNumBands()
Returns the number of bands in the underlying Raster

getBandOffsets

public final int[] getBandOffsets()
Returns the bandOffsets for the Raster if isPixelSequential() is true. Returns null otherwise. In the COPIED case, bankIndices will be numBands sequential integers starting with 0.

getPixelStride

public final int getPixelStride()
Returns the pixelStride of the underlying Raster