|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
java.awt.image.SampleModel
, MultiPixelPackedSampleModel
, SinglePixelPackedSampleModel

public abstract class SampleModel

This abstract class defines an interface for extracting samples of pixels in an image. All image data is expressed as a collection of pixels. Each pixel consists of a number of samples. A sample is a datum for one band of an image and a band consists of all samples of a particular type in an image. For example, a pixel might contain three samples representing its red, green and blue components. There are three bands in the image containing this pixel. One band consists of all the red samples from all pixels in the image. The second band consists of all the green samples and the remaining band consists of all of the blue samples. The pixel can be stored in various formats. For example, all samples from a particular band can be stored contiguously or all samples from a single pixel can be stored contiguously.
Subclasses of SampleModel specify the types of samples they can represent (e.g. unsigned 8-bit byte, signed 16-bit short, etc.) and may specify how the samples are organized in memory. In the Java 2D(tm) API, built-in image processing operators may not operate on all possible sample types, but generally will work for unsigned integral samples of 16 bits or less. Some operators support a wider variety of sample types.
A collection of pixels is represented as a Raster, which consists of a DataBuffer and a SampleModel. The SampleModel allows access to samples in the DataBuffer and may provide low-level information that a programmer can use to directly manipulate samples and pixels in the DataBuffer.
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.
DataBuffer
,
Raster
,
ComponentSampleModel
,
PixelInterleavedSampleModel
,
BandedSampleModel
,
MultiPixelPackedSampleModel
,
SinglePixelPackedSampleModel

| Field Summary | |
|---|---|
protected int |
dataType
Data type of the DataBuffer storing the pixel data. |
protected int |
height
Height in pixels of the region of image data that this SampleModel describes. |
protected int |
numBands
Number of bands of the image data that this SampleModel describes. |
protected int |
width
Width in pixels of the region of image data that this SampleModel describes. |
| Constructor Summary | |
|---|---|
SampleModel
Constructs a SampleModel with the specified parameters. |
|
| Method Summary | |
|---|---|
abstract SampleModel |
createCompatibleSampleModel
Creates a SampleModel which describes data in this SampleModel's format, but with a different width and height. |
abstract DataBuffer |
createDataBuffer
Creates a DataBuffer that corresponds to this SampleModel. |
abstract SampleModel |
createSubsetSampleModel
Creates a new SampleModel with a subset of the bands of this SampleModel. |
Object |
getDataElements
Returns the pixel data for the specified rectangle of pixels in a primitive array of type TransferType. |
abstract Object |
getDataElements
Returns data for a single pixel in a primitive array of type TransferType. |
int |
getDataType
Returns the data type of the DataBuffer storing the pixel data. |
int |
getHeight
Returns the height in pixels. |
int |
getNumBands
Returns the total number of bands of image data. |
abstract int |
getNumDataElements
Returns the number of data elements needed to transfer a pixel via the getDataElements and setDataElements methods. |
double[] |
getPixel
Returns the samples for the specified pixel in an array of double. |
float[] |
getPixel
Returns the samples for the specified pixel in an array of float. |
int[] |
getPixel
Returns the samples for a specified pixel in an int array, one sample per array element. |
double[] |
getPixels
Returns all samples for a rectangle of pixels in a double array, one sample per array element. |
float[] |
getPixels
Returns all samples for a rectangle of pixels in a float array, one sample per array element. |
int[] |
getPixels
Returns all samples for a rectangle of pixels in an int array, one sample per array element. |
abstract int |
getSample
Returns the sample in a specified band for the pixel located at (x,y) as an int. |
double |
getSampleDouble
Returns the sample in a specified band for a pixel located at (x,y) as a double. |
float |
getSampleFloat
Returns the sample in a specified band for the pixel located at (x,y) as a float. |
double[] |
getSamples
Returns the samples for a specified band for a specified rectangle of pixels in a double array, one sample per array element. |
float[] |
getSamples
Returns the samples for a specified band for the specified rectangle of pixels in a float array, one sample per array element. |
int[] |
getSamples
Returns the samples for a specified band for the specified rectangle of pixels in an int array, one sample per array element. |
abstract int[] |
getSampleSize
Returns the size in bits of samples for all bands. |
abstract int |
getSampleSize
Returns the size in bits of samples for the specified band. |
int |
getTransferType
Returns the TransferType used to transfer pixels via the getDataElements and setDataElements methods. |
int |
getWidth
Returns the width in pixels. |
void |
setDataElements
Sets the data for a rectangle of pixels in the specified DataBuffer from a primitive array of type TransferType. |
abstract void |
setDataElements
Sets the data for a single pixel in the specified DataBuffer from a primitive array of type TransferType. |
void |
setPixel
Sets a pixel in the DataBuffer using a double array of samples for input. |
void |
setPixel
Sets a pixel in the DataBuffer using a float array of samples for input. |
void |
setPixel
Sets a pixel in the DataBuffer using an int array of samples for input. |
void |
setPixels
Sets all samples for a rectangle of pixels from a double array containing one sample per array element. |
void |
setPixels
Sets all samples for a rectangle of pixels from a float array containing one sample per array element. |
void |
setPixels
Sets all samples for a rectangle of pixels from an int array containing one sample per array element. |
void |
setSample
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using a double for input. |
void |
setSample
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using a float for input. |
abstract void |
setSample
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using an int for input. |
void |
setSamples
Sets the samples in the specified band for the specified rectangle of pixels from a double array containing one sample per array element. |
void |
setSamples
Sets the samples in the specified band for the specified rectangle of pixels from a float array containing one sample per array element. |
void |
setSamples
Sets the samples in the specified band for the specified rectangle of pixels from an int array containing one sample per array element. |
Methods inherited from class java.lang.Object ![]() |
|---|
clone |
| Field Detail |
|---|

protected int width

protected int height

protected int numBands

protected int dataType
DataBuffer

| Constructor Detail |
|---|

public SampleModel(int dataType,
int w,
int h,
int numBands)
dataType - The data type of the DataBuffer storing the 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.
IllegalArgumentException

- if w or h
is not greater than 0
IllegalArgumentException

- if the product of w
and h is greater than
Integer.MAX_VALUE
IllegalArgumentException

- if dataType is not
one of the supported data types| Method Detail |
|---|

public final int getWidth()
SampleModel describes.

public final int getHeight()
SampleModel describes.

public final int getNumBands()
SampleModel describes.

public abstract int getNumDataElements()
getDataElements(int, int, Object, DataBuffer)
,
getDataElements(int, int, int, int, Object, DataBuffer)
,
setDataElements(int, int, Object, DataBuffer)
,
setDataElements(int, int, int, int, Object, DataBuffer)
,
getTransferType()


public final int getDataType()

public int getTransferType()
getDataElements(int, int, Object, DataBuffer)
,
getDataElements(int, int, int, int, Object, DataBuffer)
,
setDataElements(int, int, Object, DataBuffer)
,
setDataElements(int, int, int, int, Object, DataBuffer)
,
getNumDataElements()
,
DataBuffer


public int[] getPixel(int x,
int y,
int[] iArray,
DataBuffer