All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class java.awt.image.SampleModel

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

public abstract class SampleModel
extends Object
This abstract class defines an interface for extracting samples of an image without knowing how the underlying data is stored in a DataBuffer. All image data is expressed as a collection of pixels. Each pixel consists of a number of samples. A sample is a collection of data for one band of an image. This class is generally a fall back method for dealing with images. More efficient code will cast the SampleModel to the appropriate subclass and extract the information needed to directly manipulate pixels in the DataBuffer.

See Also:
DataBuffer, ComponentSampleModel, BandedSampleModel, SingleBandPackedSampleModel, MultiBandPackedSampleModel

Variable Index

 o dataType
Data type of the underlying pixel data.
 o height
Height of the region of image data that this SampleModel describes.
 o numBands
number of bands of the inage data that this SampleModel describes.
 o width
Width of the region of image data that this SampleModel describes.

Constructor Index

 o SampleModel(int, int, int, int)
Constructs a SampleModel with the specified parameters.

Method Index

 o createCompatibleDataBuffer()
Creates a DataBuffer that corresponds to this SampleModel.
 o createCompatibleDataBuffer(int, int)
Creates a DataBuffer that corresponds to this SampleModel, with a different width and height.
 o createCompatibleSampleModel(int, int)
Creates a SampleModel which describes data in this SampleModel's format, but with a different width and height.
 o createSubsetSampleModel(int, int, int[])
This creates a new SampleModel with the requested width and height and with a subset of the bands of this SampleModel.
 o getDataType()
Returns the data type.
 o getHeight()
Returns the height in pixels.
 o getMaxSampleValue()
Returns the maximum sample value for all bands.
 o getMaxSampleValue(int)
Returns the maximum sample value for the specified band.
 o getMinSampleValue()
Returns the minimum sample value for all bands.
 o getMinSampleValue(int)
Returns the minimum sample value for the specified band.
 o getNumBands()
Returns the total number of bands of image data.
 o getNumDataElements()
Returns the number of data elements needed to store a pixel.
 o getPixel(int, int, double[], DataBuffer)
Returns the samples for the specified pixle in an array of double.
 o getPixel(int, int, float[], DataBuffer)
Returns the samples for the specified pixel in an array of float.
 o getPixel(int, int, int, int, double[], DataBuffer)
Returns all samples for a rectangle of pixels in a double array, one sample per array element.
 o getPixel(int, int, int, int, float[], DataBuffer)
Returns all samples for a rectangle of pixels in a float array, one sample per array element.
 o getPixel(int, int, int, int, int[], DataBuffer)
Returns all samples for a rectangle of pixels in an int array, one sample per array element.
 o getPixel(int, int, int[], DataBuffer)
Returns the samples for a specified pixel in an array of int.
 o getPixelData(int, int, int, int, Object, DataBuffer)
Returns the pixel data for the specified rectangle in an array of primitives that can be byte, short or int.
 o getPixelData(int, int, Object, DataBuffer)
Returns the pixel data in an array of primitives that can be byte, short or int.
 o getSample(int, int, int, DataBuffer)
Returns the sample in a specified band for the pixel located at (x,y) as an int.
 o getSample(int, int, int, int, int, double[], DataBuffer)
Returns the samples for a specified band for a specified rectangle of pixels in a double array, one sample per array element.
 o getSample(int, int, int, int, int, float[], DataBuffer)
Returns the samples for a specified band for the specified rectangle of pixels in a float array, one sample per array element.
 o getSample(int, int, int, int, int, int[], DataBuffer)
Returns the samples for a specified band for the specified rectangle of pixels in an int array, one sample per array element.
 o getSampleDouble(int, int, int, DataBuffer)
Returns the sample in a specified band for a pixel located at (x,y) as a double.
 o getSampleFloat(int, int, int, DataBuffer)
Returns the sample in a specified band for the pixel located at (x,y) as a float.
 o getSampleSize()
Returns the size in bits of samples for all bands.
 o getSampleSize(int)
Returns the size in bits of samples for the specified band.
 o getTransferType()
Returns the transfer type of the data.
 o getWidth()
Returns the width in pixels.
 o setPixel(int, int, double[], DataBuffer)
Sets a pixel in the DataBuffer using a double array of samples for input.
 o setPixel(int, int, float[], DataBuffer)
Sets a pixel in the DataBuffer using a float array of samples for input.
 o setPixel(int, int, int, int, double[], DataBuffer)
Sets all samples for a rectangle of pixels from a double array containing one sample per array element.
 o setPixel(int, int, int, int, float[], DataBuffer)
Sets all samples for a rectangle of pixels from a float array containing one sample per array element.
 o setPixel(int, int, int, int, int[], DataBuffer)
Sets all samples for a rectangle of pixels from an int array containing one sample per array element.
 o setPixel(int, int, int[], DataBuffer)
Sets a pixel in the DataBuffer using an int array of samples for input.
 o setPixelData(int, int, Object, DataBuffer)
Puts the pixel data from an Object that contains an array of primitives that can be byte, short or int.
 o setSample(int, int, int, double, DataBuffer)
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using a double for input.
 o setSample(int, int, int, float, DataBuffer)
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using a float for input.
 o setSample(int, int, int, int, DataBuffer)
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using an int for input.
 o setSample(int, int, int, int, int, double[], DataBuffer)
Sets the samples in the specified band for the specified rectangle of pixels from a double array containing one sample per array element.
 o setSample(int, int, int, int, int, float[], DataBuffer)
Sets the samples in the specified band for the specified rectangle of pixels from a float array containing one sample per array element.
 o setSample(int, int, int, int, int, int[], DataBuffer)
Sets the samples in the specified band for the specified rectangle of pixels from an int array containing one sample per array element.

Variables

 o width
protected int width
Width of the region of image data that this SampleModel describes.

 o height
protected int height
Height of the region of image data that this SampleModel describes.

 o numBands
protected int numBands
number of bands of the inage data that this SampleModel describes.

 o dataType
protected int dataType
Data type of the underlying pixel data.

Constructors

 o SampleModel
public SampleModel(int dataType,
                   int w,
                   int h,
                   int numBands)
Constructs a SampleModel with the specified parameters.

Parameters:
dataType - the data type of the underlying pixel data.
w - The width (in pixels) of the region of image data.
h - The height (in pixels) of the region of image data.
numBands - The number of bands of the image data.

Methods

 o getWidth
public final int getWidth()
Returns the width in pixels.

 o getHeight
public final int getHeight()
Returns the height in pixels.

 o getNumBands
public final int getNumBands()
Returns the total number of bands of image data.

 o getNumDataElements
public abstract int getNumDataElements()
Returns the number of data elements needed to store a pixel.

 o getDataType
public final int getDataType()
Returns the data type.

 o getTransferType
public abstract int getTransferType()
Returns the transfer type of the data.

 o getPixel
public int[] getPixel(int x,
                      int y,
                      int[] iArray,
                      DataBuffer data)
Returns the samples for a specified pixel in an array of int.

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.
 o getPixelData
public abstract 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.
 	     SampleModel sm1, sm2;
	     DataBuffer db1, db2;
 	     sm2.setPixelData(x, y, sm1.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.
 o getPixelData
public Object getPixelData(int x,
                           int y,
                           int w,
                           int h,
                           Object obj,
                           DataBuffer data)
Returns the pixel data for the specified rectangle 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.
 	     SampleModel sm1, sm2;
	     DataBuffer db1, db2;
 	     sm2.setPixelData(x, y, w, h, sm1.getPixelData(x, y, w,
 h, null, db1), db2);
 

Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
w - The width of the pixel rectangle.
h - The height of the pixel rectangle.
obj - If non-null, returns the primitive array in this object.
data - The DataBuffer containing the image data.
 o setPixelData
public abstract 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.
 	     SampleModel sm1, sm2;
	     DataBuffer db1, db2;
 	     sm2.setPixelData(x, y, sm1.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.
 o getPixel
public float[] getPixel(int x,
                        int y,
                        float[] fArray,
                        DataBuffer data)
Returns the samples for the specified pixel in an array of float.

Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
fArray - If non-null, returns the samples in this array.
data - The DataBuffer containing the image data.
 o getPixel
public double[] getPixel(int x,
                         int y,
                         double[] dArray,
                         DataBuffer data)
Returns the samples for the specified pixle in an array of double.

Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
dArray - If non-null, returns the samples in this array.
data - The DataBuffer containing the image data.
 o getPixel
public int[] getPixel(int x,
                      int y,
                      int w,
                      int h,
                      int[] iArray,
                      DataBuffer data)
Returns all samples for a rectangle of pixels in an int array, 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 - If non-null, returns the samples in this array.
data - The DataBuffer containing the image data.
 o getPixel
public float[] getPixel(int x,
                        int y,
                        int w,
                        int h,
                        float[] fArray,
                        DataBuffer data)
Returns all samples for a rectangle of pixels in a float array, 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.
fArray - If non-null, returns the samples in this array.
data - The DataBuffer containing the image data.
 o getPixel
public double[] getPixel(int x,
                         int y,
                         int w,
                         int h,
                         double[] dArray,
                         DataBuffer data)
Returns all samples for a rectangle of pixels in a double array, 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.
dArray - If non-null, returns the samples in this array.
data - The DataBuffer containing the image data.
 o getSample
public abstract int getSample(int x,
                              int y,
                              int b,
                              DataBuffer data)
Returns the sample in a specified band for the pixel located at (x,y) as an int.

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.
 o getSampleFloat
public float getSampleFloat(int x,
                            int y,
                            int b,
                            DataBuffer data)
Returns the sample in a specified band for the pixel located at (x,y) as a float.

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.
 o getSampleDouble
public double getSampleDouble(int x,
                              int y,
                              int b,
                              DataBuffer data)
Returns the sample in a specified band for a pixel located at (x,y) as a double.

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.
 o getSample
public int[] getSample(int x,
                       int y,
                       int w,
                       int h,
                       int b,
                       int[] iArray,
                       DataBuffer data)
Returns the samples for a specified band for the specified rectangle of pixels in an int array, 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.
b - The band to return.
iArray - If non-null, returns the samples in this array.
data - The DataBuffer containing the image data.
 o getSample
public float[] getSample(int x,
                         int y,
                         int w,
                         int h,
                         int b,
                         float[] fArray,
                         DataBuffer data)
Returns the samples for a specified band for the specified rectangle of pixels in a float array, 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.
b - The band to return.
fArray - If non-null, returns the samples in this array.
data - The DataBuffer containing the image data.
 o getSample
public double[] getSample(int x,
                          int y,
                          int w,
                          int h,
                          int b,
                          double[] dArray,
                          DataBuffer data)
Returns the samples for a specified band for a specified rectangle of pixels in a double array, 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.
b - The band to return.
dArray - If non-null, returns the samples in this array.
data - The DataBuffer containing the image data.
 o 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.
 o setPixel
public void setPixel(int x,
                     int y,
                     float[] fArray,
                     DataBuffer data)
Sets a pixel in the DataBuffer using a float array of samples for input.

Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
fArray - The input samples in a float array.
data - The DataBuffer containing the image data.
 o setPixel
public void setPixel(int x,
                     int y,
                     double[] dArray,
                     DataBuffer data)
Sets a pixel in the DataBuffer using a double array of samples for input.

Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
dArray - The input samples in a double array.
data - The DataBuffer containing the image data.
 o 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.
 o setPixel
public void setPixel(int x,
                     int y,
                     int w,
                     int h,
                     float[] fArray,
                     DataBuffer data)
Sets all samples for a rectangle of pixels from a float 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.
fArray - The input samples in a float array.
data - The DataBuffer containing the image data.
 o setPixel
public void setPixel(int x,
                     int y,
                     int w,
                     int h,
                     double[] dArray,
                     DataBuffer data)
Sets all samples for a rectangle of pixels from a double 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.
dArray - The input samples in a double array.
data - The DataBuffer containing the image data.
 o setSample
public abstract 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.
 o setSample
public void setSample(int x,
                      int y,
                      int b,
                      float s,
                      DataBuffer data)
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using a float 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 a float.
data - The DataBuffer containing the image data.
 o setSample
public void setSample(int x,
                      int y,
                      int b,
                      double s,
                      DataBuffer data)
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using a double 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 a double.
data - The DataBuffer containing the image data.
 o 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 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 samples in an int array.
data - The DataBuffer containing the image data.
 o setSample
public void setSample(int x,
                      int y,
                      int w,
                      int h,
                      int b,
                      float[] fArray,
                      DataBuffer data)
Sets the samples in the specified band for the specified rectangle of pixels from a float 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.
b - The band to set.
fArray - The input samples in a float array.
data - The DataBuffer containing the image data.
 o setSample
public void setSample(int x,
                      int y,
                      int w,
                      int h,
                      int b,
                      double[] dArray,
                      DataBuffer data)
Sets the samples in the specified band for the specified rectangle of pixels from a double 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.
b - The band to set.
dArray - The input samples in a double array.
data - The DataBuffer containing the image data.
 o createCompatibleSampleModel
public abstract SampleModel createCompatibleSampleModel(int w,
                                                        int h)
Creates a SampleModel which describes data in this SampleModel's format, but with a different width and height.

 o createSubsetSampleModel
public abstract SampleModel createSubsetSampleModel(int w,
                                                    int h,
                                                    int[] bands)
This creates a new SampleModel with the requested width and height and with a subset of the bands of this SampleModel.

 o createCompatibleDataBuffer
public abstract DataBuffer createCompatibleDataBuffer()
Creates a DataBuffer that corresponds to this SampleModel. The DataBuffer's width and height will match this SampleModel's.

 o createCompatibleDataBuffer
public abstract DataBuffer createCompatibleDataBuffer(int width,
                                                      int height)
Creates a DataBuffer that corresponds to this SampleModel, with a different width and height.

 o getMinSampleValue
public float getMinSampleValue()
Returns the minimum sample value for all bands.

 o getMinSampleValue
public float getMinSampleValue(int band)
Returns the minimum sample value for the specified band.

 o getMaxSampleValue
public float getMaxSampleValue()
Returns the maximum sample value for all bands.

 o getMaxSampleValue
public float getMaxSampleValue(int band)
Returns the maximum sample value for the specified band.

 o getSampleSize
public abstract int[] getSampleSize()
Returns the size in bits of samples for all bands.

 o getSampleSize
public abstract int getSampleSize(int band)
Returns the size in bits of samples for the specified band.


All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Submit a bug or feature