Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Class java.awt.image.BandedSampleModel

java.lang.Object
    |
    +----java.awt.image.SampleModel
            |
            +----java.awt.image.BandedSampleModel

public class BandedSampleModel
extends SampleModel
This class extends the SampleModel. It provides more efficent implementations for accessing image data than are provided in SampleModel. This class will be used when working with images which store sample data for each band in a different bank of the DataBuffer. Accessor methods are provided so that image data can be manipulated directly. Pixelstride is the number of data array elements between two samples for the same band on the same scanline. Scanlinestride is the number of data array elements between a given sample and the sample in the same column of the next scanline. Bank Index denotes the correspondence between a bank of the data buffer and a band of image data. The image bands and the DataBuffer banks are numbered from 0 to n-1.


Fields inherited from class java.awt.image.SampleModel
 dataType, height, numBands, width
 

Constructor Summary
 BandedSampleModel(int dataType, int w, int h, int numBands)
Constructs a BandedSampleModel with the specified parameters.
 BandedSampleModel(int dataType, int w, int h, int numBands, int scanlineStride, int pixelStride, int[] bankIndices)
Constructs a BandedSampleModel with the specified parameters.
 

Method Summary
DataBuffer  createCompatibleDataBuffer()
Creates a DataBuffer that corresponds to this BandedSampleModel, The DataBuffer's width and height will match this BandedSampleModel's.
DataBuffer  createCompatibleDataBuffer(int desiredWidth, int desiredHeight)
Creates a DataBuffer that corresponds to this BandedSampleModel, with a different width and height.
SampleModel  createCompatibleSampleModel(int w, int h)
This creates a new BandedSampleModel with the specified width and height.
SampleModel  createSubsetSampleModel(int w, int h, int[] bands)
This creates a new SampleModel with the specified width and height and with a subset of the bands of this SampleModel.
int[]  getBankIndices()
Returns the bank indices for all bands.
int  getNumDataElements()
Returns the number of data elements required to store one pixel.
long  getOffset(int x, int y)
Gets offset of the first band of pixel (x,y).
int[]  getPixel(int x, int y, int[] iArray, DataBuffer data)
Returns all samples for the specified pixel in an int array.
int[]  getPixel(int x, int y, int w, int h, int[] iArray, DataBuffer data)
Returns all samples for the specified rectangle of pixels in an int array, one sample per data array element.
Object  getPixelData(int x, int y, Object obj, DataBuffer data)
Returns the pixel data in an array of primitives that can be byte, short or int.
int  getPixelStride()
Returns the pixel stride of this BandedSampleModel.
int  getSample(int x, int y, int b, DataBuffer data)
Returns as int the sample in a specified band for the pixel located at (x,y).
int[]  getSample(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
Returns the samples in a specified band for the specified rectangle of pixels in an int array, one sample per data array element.
int[]  getSampleSize()
Returns the size in bits of samples for all bands.
int  getSampleSize(int band)
Returns the size in bits of samples for the specified band.
int  getScanlineStride()
Returns the scanline stride of this BandedSampleModel.
int  getTransferType()
Returns the transfer type of the underlying data.
void  setPixel(int x, int y, int[] iArray, DataBuffer data)
Sets a pixel in the DataBuffer using an int array of samples for input.
void  setPixel(int x, int y, int w, int h, int[] iArray, DataBuffer data)
Sets all samples for a rectangle of pixels from an int array containing one sample per array element.
void  setPixelData(int x, int y, Object obj, DataBuffer data)
Puts the pixel data from an Object that contains an array of primitives that can be byte, short or int.
void  setSample(int x, int y, int b, int s, DataBuffer data)
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using an int for input.
void  setSample(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
Sets the samples in the specified band for the specified rectangle of pixels from an int array containing one sample per data array element.
 
Methods inherited from class java.awt.image.SampleModel
 createCompatibleDataBuffer, createCompatibleDataBuffer, createCompatibleSampleModel, createSubsetSampleModel, getDataType, getHeight, getMaxSampleValue, getMaxSampleValue, getMinSampleValue, getMinSampleValue, getNumBands, getNumDataElements, getPixel, getPixel, getPixel, getPixel, getPixel, getPixel, getPixelData, getPixelData, getSample, getSample, getSample, getSample, getSampleDouble, getSampleFloat, getSampleSize, getSampleSize, getTransferType, getWidth, setPixel, setPixel, setPixel, setPixel, setPixel, setPixel, setPixelData, setSample, setSample, setSample, setSample, setSample, setSample
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BandedSampleModel

public BandedSampleModel(int dataType,
                         int w,
                         int h,
                         int numBands)
Constructs a BandedSampleModel with the specified parameters. The number of bands will be given by the length of the bandOffsets array.
Parameters:
dataType - The data type for storing samples.
w - The width (in pixels) of the region of image data described.
h - The height (in pixels) of the region of image data described.
numBands - The number of bands for the region of image data described.

BandedSampleModel

public BandedSampleModel(int dataType,
                         int w,
                         int h,
                         int numBands,
                         int scanlineStride,
                         int pixelStride,
                         int[] bankIndices)
Constructs a BandedSampleModel with the specified parameters.
Parameters:
dataType - The data type for storing samples.
w - The width (in pixels) of the region of image data described.
h - The height (in pixels) of the region of image data described.
numBands - The number of bands for the region of image data described.
scanlineStride - The line stride of the region of the image data described.
pixelStride - The pixel stride of the region of image data described.
bankIndices - The bank index for each band.
Method Detail

createCompatibleSampleModel

public SampleModel createCompatibleSampleModel(int w,
                                               int h)
This creates a new BandedSampleModel with the specified width and height. As much as possible the 'style' of the current BandedSampleModel will be preserved.
Overrides:
createCompatibleSampleModel in class SampleModel

createSubsetSampleModel

public SampleModel createSubsetSampleModel(int w,
                                           int h,
                                           int[] bands)
This creates a new SampleModel with the specified width and height and with a subset of the bands of this SampleModel. Here there will be no explicit check made to ensure that the subset bands asked for actually exist in the parent.
Overrides:
createSubsetSampleModel in class SampleModel

createCompatibleDataBuffer

public DataBuffer createCompatibleDataBuffer()
Creates a DataBuffer that corresponds to this BandedSampleModel, The DataBuffer's width and height will match this BandedSampleModel's.
Overrides:
createCompatibleDataBuffer in class SampleModel

createCompatibleDataBuffer

public DataBuffer createCompatibleDataBuffer(int desiredWidth,
                                             int desiredHeight)
Creates a DataBuffer that corresponds to this BandedSampleModel, with a different width and height.
Overrides:
createCompatibleDataBuffer in class SampleModel

getOffset

public long getOffset(int x,
                      int y)
Gets offset of the first band of pixel (x,y). A sample of the first band can be retrieved from a dataBuffer data with a BandedSampleModel bsm as
       data.getElem(bsm.getOffset(x, y));
  

getSampleSize

public int[] getSampleSize()
Returns the size in bits of samples for all bands.
Overrides:
getSampleSize in class SampleModel

getSampleSize

public int getSampleSize(int band)
Returns the size in bits of samples for the specified band.
Overrides:
getSampleSize in class SampleModel

getBankIndices

public int[] getBankIndices()
Returns the bank indices for all bands.

getScanlineStride

public int getScanlineStride()
Returns the scanline stride of this BandedSampleModel.

getPixelStride

public int getPixelStride()
Returns the pixel stride of this BandedSampleModel.

getNumDataElements

public int getNumDataElements()
Returns the number of data elements required to store one pixel. For a BandedSampleModel, this is identical to the number of bands.
Overrides:
getNumDataElements in class SampleModel

getTransferType

public int getTransferType()
Returns the transfer type of the underlying data. For a ComponentSampleModel, this is identical to the dataType.
Overrides:
getTransferType in class SampleModel

getPixelData

public Object getPixelData(int x,
                           int y,
                           Object obj,
                           DataBuffer data)
Returns the pixel data in an array of primitives that can be byte, short or int. Which primitive type is returned depends on the transfer type. Data is returned in the packed format, thus increasing efficiency for data transfers. Generally, obj should be passed in as null, so that the Object will be created automatically and will be of the right primitive data type.
 	     BandedSampleModel bsm1, bsm2;
	     DataBufferInt db1, db2;
 	     bsm2.setPixelData(x, y, bsm1.getPixelData(x, y, null, db1), db2);
 
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
obj - If non-null, returns the primitive array in this object.
data - The DataBuffer containing the image data.
Overrides:
getPixelData in class SampleModel

getPixel

public int[] getPixel(int x,
                      int y,
                      int[] iArray,
                      DataBuffer data)
Returns all samples for the specified pixel in an int array.
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
iArray - If non-null, returns the samples in this array.
data - The DataBuffer containing the image data.
Overrides:
getPixel in class SampleModel

getPixel

public int[] getPixel(int x,
                      int y,
                      int w,
                      int h,
                      int[] iArray,
                      DataBuffer data)
Returns all samples for the specified rectangle of pixels in an int array, one sample per data array element.
Parameters:
x - The X coordinate of the upper left pixel location.
y - The Y coordinate of the upper left pixel location.
w - The width of the pixel rectangle.
h - The height of the pixel rectangle.
iArray - If non-null, returns the samples in this array.
data - The DataBuffer containing the image data.
Overrides:
getPixel in class SampleModel

getSample

public int getSample(int x,
                     int y,
                     int b,
                     DataBuffer data)
Returns as int the sample in a specified band for the pixel located at (x,y).
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
b - The band to return.
data - The DataBuffer containing the image data.
Overrides:
getSample in class SampleModel

getSample

public int[] getSample(int x,
                       int y,
                       int w,
                       int h,
                       int b,
                       int[] iArray,
                       DataBuffer data)
Returns the samples in a specified band for the specified rectangle of pixels in an int array, one sample per data array element.
Parameters:
x - The X coordinate of the upper left pixel location.
y - The Y coordinate of the upper left pixel location.
w - The width of the pixel rectangle.
h - The height of the pixel rectangle.
b - The band to return.
iArray - If non-null, returns the samples in this array.
data - The DataBuffer containing the image data.
Overrides:
getSample in class SampleModel

setPixelData

public void setPixelData(int x,
                         int y,
                         Object obj,
                         DataBuffer data)
Puts the pixel data from an Object that contains an array of primitives that can be byte, short or int. Which primitive type it contains depends on the transfer type. Data in the Object is in the packed format, thus increasing efficiency for data transfers.
 	     BandedSampleModel bsm1, bsm2;
	     DataBufferInt db1, db2;
 	     bsm2.setPixelData(x, y, bsm1.getPixelData(x, y, null, db1), db2);
 
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
obj - If non-null, returns the primitive array in this object.
data - The DataBuffer containing the image data.
Overrides:
setPixelData in class SampleModel

setPixel

public void setPixel(int x,
                     int y,
                     int[] iArray,
                     DataBuffer data)
Sets a pixel in the DataBuffer using an int array of samples for input.
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
iArray - The input samples in an int array.
data - The DataBuffer containing the image data.
Overrides:
setPixel in class SampleModel

setPixel

public void setPixel(int x,
                     int y,
                     int w,
                     int h,
                     int[] iArray,
                     DataBuffer data)
Sets all samples for a rectangle of pixels from an int array containing one sample per array element.
Parameters:
x - The X coordinate of the upper left pixel location.
y - The Y coordinate of the upper left pixel location.
w - The width of the pixel rectangle.
h - The height of the pixel rectangle.
iArray - The input samples in an int array.
data - The DataBuffer containing the image data.
Overrides:
setPixel in class SampleModel

setSample

public void setSample(int x,
                      int y,
                      int b,
                      int s,
                      DataBuffer data)
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using an int for input.
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
b - The band to set.
s - The input sample as an int.
data - The DataBuffer containing the image data.
Overrides:
setSample in class SampleModel

setSample

public void setSample(int x,
                      int y,
                      int w,
                      int h,
                      int b,
                      int[] iArray,
                      DataBuffer data)
Sets the samples in the specified band for the specified rectangle of pixels from an int array containing one sample per data array element.
Parameters:
x - The X coordinate of the upper left pixel location.
y - The Y coordinate of the upper left pixel location.
w - The width of the pixel rectangle.
h - The height of the pixel rectangle.
b - The band to set.
iArray - The input sample array.
data - The DataBuffer containing the image data.
Overrides:
setSample in class SampleModel

Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.