Class SampleModel
- Direct Known Subclasses:
-
ComponentSampleModel
,MultiPixelPackedSampleModel
,SinglePixelPackedSampleModel
public abstract class SampleModel extends Object
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.
Field Summary
Modifier and Type | Field | Description |
---|---|---|
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
Constructor | Description |
---|---|
SampleModel |
Constructs a SampleModel with the specified parameters. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
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. |
final int |
getDataType() |
Returns the data type of the DataBuffer storing the pixel data. |
final int |
getHeight() |
Returns the height in pixels. |
final 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. |
final 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. |
Field Details
width
protected int width
height
protected int height
numBands
protected int numBands
dataType
protected int dataType
- See Also:
Constructor Details
SampleModel
public SampleModel(int dataType, int w, int h, int numBands)
- Parameters:
-
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. - Throws:
-
IllegalArgumentException
- ifw
orh
is not greater than 0 -
IllegalArgumentException
- if the product ofw
andh
is greater thanInteger.MAX_VALUE
-
IllegalArgumentException
- ifdataType
is not one of the pre-defined data type tags in theDataBuffer
class -
IllegalArgumentException
- ifnumBands
is less than 1
Method Details
getWidth
public final int getWidth()
- Returns:
- the width in pixels of the region of image data that this
SampleModel
describes.
getHeight
public final int getHeight()
- Returns:
- the height in pixels of the region of image data that this
SampleModel
describes.
getNumBands
public final int getNumBands()
- Returns:
- the number of bands of image data that this
SampleModel
describes.
getNumDataElements
public abstract int getNumDataElements()
getDataType
public final int getDataType()
- Returns:
- the data type.
getTransferType
public int getTransferType()
getPixel
public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
- 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 - Returns:
- the samples for the specified pixel.
- Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if iArray is too small to hold the output. - See Also:
getDataElements
public abstract Object getDataElements(int x, int y, Object obj, DataBuffer data)
The following code illustrates transferring data for one pixel from DataBuffer db1
, whose storage layout is described by SampleModel sm1
, to DataBuffer db2
, whose storage layout is described by SampleModel sm2
. The transfer will generally be more efficient than using getPixel/setPixel.
SampleModel sm1, sm2; DataBuffer db1, db2; sm2.setDataElements(x, y, sm1.getDataElements(x, y, null, db1), db2);Using getDataElements/setDataElements to transfer between two DataBuffer/SampleModel pairs is legitimate if the SampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same.
If obj is non-null, it should be a primitive array of type TransferType. Otherwise, a ClassCastException is thrown. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds, or if obj is non-null and is not large enough to hold the pixel data.
- Parameters:
-
x
- The X coordinate of the pixel location. -
y
- The Y coordinate of the pixel location. -
obj
- If non-null, a primitive array in which to return the pixel data. -
data
- The DataBuffer containing the image data. - Returns:
- the data elements for the specified pixel.
- Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if obj is too small to hold the output. - See Also:
getDataElements
public Object getDataElements(int x, int y, int w, int h, Object obj, DataBuffer data)
The following code illustrates transferring data for a rectangular region of pixels from DataBuffer db1
, whose storage layout is described by SampleModel sm1
, to DataBuffer db2
, whose storage layout is described by SampleModel sm2
. The transfer will generally be more efficient than using getPixels/setPixels.
SampleModel sm1, sm2; DataBuffer db1, db2; sm2.setDataElements(x, y, w, h, sm1.getDataElements(x, y, w, h, null, db1), db2);Using getDataElements/setDataElements to transfer between two DataBuffer/SampleModel pairs is legitimate if the SampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same.
If obj is non-null, it should be a primitive array of type TransferType. Otherwise, a ClassCastException is thrown. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds, or if obj is non-null and is not large enough to hold the pixel data.
- Parameters:
-
x
- The minimum X coordinate of the pixel rectangle. -
y
- The minimum Y coordinate of the pixel rectangle. -
w
- The width of the pixel rectangle. -
h
- The height of the pixel rectangle. -
obj
- If non-null, a primitive array in which to return the pixel data. -
data
- The DataBuffer containing the image data. - Returns:
- the data elements for the specified region of pixels.
- Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if obj is too small to hold the output. - See Also:
setDataElements
public abstract void setDataElements(int x, int y, Object obj, DataBuffer data)
The following code illustrates transferring data for one pixel from DataBuffer db1
, whose storage layout is described by SampleModel sm1
, to DataBuffer db2
, whose storage layout is described by SampleModel sm2
. The transfer will generally be more efficient than using getPixel/setPixel.
SampleModel sm1, sm2; DataBuffer db1, db2; sm2.setDataElements(x, y, sm1.getDataElements(x, y, null, db1), db2);Using getDataElements/setDataElements to transfer between two DataBuffer/SampleModel pairs is legitimate if the SampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same.
obj must be a primitive array of type TransferType. Otherwise, a ClassCastException is thrown. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds, or if obj is not large enough to hold the pixel data.
- Parameters:
-
x
- The X coordinate of the pixel location. -
y
- The Y coordinate of the pixel location. -
obj
- A primitive array containing pixel data. -
data
- The DataBuffer containing the image data. - Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if obj is too small to hold the input. - See Also:
setDataElements
public void setDataElements(int x, int y, int w, int h, Object obj, DataBuffer data)
The following code illustrates transferring data for a rectangular region of pixels from DataBuffer db1
, whose storage layout is described by SampleModel sm1
, to DataBuffer db2
, whose storage layout is described by SampleModel sm2
. The transfer will generally be more efficient than using getPixels/setPixels.
SampleModel sm1, sm2; DataBuffer db1, db2; sm2.setDataElements(x, y, w, h, sm1.getDataElements(x, y, w, h, null, db1), db2);Using getDataElements/setDataElements to transfer between two DataBuffer/SampleModel pairs is legitimate if the SampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same.
obj must be a primitive array of type TransferType. Otherwise, a ClassCastException is thrown. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds, or if obj is not large enough to hold the pixel data.
- Parameters:
-
x
- The minimum X coordinate of the pixel rectangle. -
y
- The minimum Y coordinate of the pixel rectangle. -
w
- The width of the pixel rectangle. -
h
- The height of the pixel rectangle. -
obj
- A primitive array containing pixel data. -
data
- The DataBuffer containing the image data. - Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if obj is too small to hold the input. - See Also:
getPixel
public float[] getPixel(int x, int y, float[] fArray, DataBuffer data)
- 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. - Returns:
- the samples for the specified pixel.
- Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if fArray is too small to hold the output. - See Also:
getPixel
public double[] getPixel(int x, int y, double[] dArray, DataBuffer data)
- 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. - Returns:
- the samples for the specified pixel.
- Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if dArray is too small to hold the output. - See Also:
getPixels
public int[] getPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
- 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. - Returns:
- the samples for the specified region of pixels.
- Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if iArray is too small to hold the output. - See Also:
getPixels
public float[] getPixels(int x, int y, int w, int h, float[] fArray, DataBuffer data)
- 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. - Returns:
- the samples for the specified region of pixels.
- Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if fArray is too small to hold the output. - See Also:
getPixels
public double[] getPixels(int x, int y, int w, int h, double[] dArray, DataBuffer data)
- 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. - Returns:
- the samples for the specified region of pixels.
- Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if dArray is too small to hold the output. - See Also:
getSample
public abstract int getSample(int x, int y, int b, DataBuffer data)
- 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. - Returns:
- the sample in a specified band for the specified pixel.
- Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates or the band index are not in bounds. - See Also:
getSampleFloat
public float getSampleFloat(int x, int y, int b, DataBuffer data)
- 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. - Returns:
- the sample in a specified band for the specified pixel.
- Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates or the band index are not in bounds.
getSampleDouble
public double getSampleDouble(int x, int y, int b, DataBuffer data)
- 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. - Returns:
- the sample in a specified band for the specified pixel.
- Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates or the band index are not in bounds.
getSamples
public int[] getSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
- 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. - Returns:
- the samples for the specified band for the specified region of pixels.
- Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates or the band index are not in bounds, or if iArray is too small to hold the output. - See Also:
getSamples
public float[] getSamples(int x, int y, int w, int h, int b, float[] fArray, DataBuffer data)
- 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. - Returns:
- the samples for the specified band for the specified region of pixels.
- Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates or the band index are not in bounds, or if fArray is too small to hold the output. - See Also:
getSamples
public double[] getSamples(int x, int y, int w, int h, int b, double[] dArray, DataBuffer data)
- 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. - Returns:
- the samples for the specified band for the specified region of pixels.
- Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates or the band index are not in bounds, or if dArray is too small to hold the output. - See Also:
setPixel
public void setPixel(int x, int y, int[] iArray, DataBuffer data)
- 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. - Throws:
-
NullPointerException
- if iArray or data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if iArray is too small to hold the input. - See Also:
setPixel
public void setPixel(int x, int y, float[] fArray, DataBuffer data)
- 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. - Throws:
-
NullPointerException
- if fArray or data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if fArray is too small to hold the input. - See Also:
setPixel
public void setPixel(int x, int y, double[] dArray, DataBuffer data)
- 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. - Throws:
-
NullPointerException
- if dArray or data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if fArray is too small to hold the input. - See Also:
setPixels
public void setPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
- 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. - Throws:
-
NullPointerException
- if iArray or data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if iArray is too small to hold the input. - See Also:
setPixels
public void setPixels(int x, int y, int w, int h, float[] fArray, DataBuffer data)
- 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. - Throws:
-
NullPointerException
- if fArray or data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if fArray is too small to hold the input. - See Also:
setPixels
public void setPixels(int x, int y, int w, int h, double[] dArray, DataBuffer data)
- 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. - Throws:
-
NullPointerException
- if dArray or data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates are not in bounds, or if dArray is too small to hold the input. - See Also:
setSample
public abstract void setSample(int x, int y, int b, int s, DataBuffer data)
- 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. - Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates or the band index are not in bounds. - See Also:
setSample
public void setSample(int x, int y, int b, float s, DataBuffer data)
setSample(int, int, int, DataBuffer)
method using that int value. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.- 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. - Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates or the band index are not in bounds. - See Also:
setSample
public void setSample(int x, int y, int b, double s, DataBuffer data)
setSample(int, int, int, DataBuffer)
method using that int value. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.- 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. - Throws:
-
NullPointerException
- if data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates or the band index are not in bounds. - See Also:
setSamples
public void setSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
- 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. - Throws:
-
NullPointerException
- if iArray or data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates or the band index are not in bounds, or if iArray is too small to hold the input. - See Also:
setSamples
public void setSamples(int x, int y, int w, int h, int b, float[] fArray, DataBuffer data)
- 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. - Throws:
-
NullPointerException
- if fArray or data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates or the band index are not in bounds, or if fArray is too small to hold the input. - See Also:
setSamples
public void setSamples(int x, int y, int w, int h, int b, double[] dArray, DataBuffer data)
- 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. - Throws:
-
NullPointerException
- if dArray or data is null. -
ArrayIndexOutOfBoundsException
- if the coordinates or the band index are not in bounds, or if dArray is too small to hold the input. - See Also:
createCompatibleSampleModel
public abstract SampleModel createCompatibleSampleModel(int w, int h)
- Parameters:
-
w
- the width of the image data -
h
- the height of the image data - Returns:
- a
SampleModel
describing the same image data as thisSampleModel
, but with a different size.
createSubsetSampleModel
public abstract SampleModel createSubsetSampleModel(int[] bands)
- Parameters:
-
bands
- the subset of bands of thisSampleModel
- Returns:
- a
SampleModel
with a subset of bands of thisSampleModel
.
createDataBuffer
public abstract DataBuffer createDataBuffer()
- Returns:
- a
DataBuffer
corresponding to thisSampleModel
.
getSampleSize
public abstract int[] getSampleSize()
- Returns:
- the size of samples for all bands.
getSampleSize
public abstract int getSampleSize(int band)
- Parameters:
-
band
- the specified band - Returns:
- the size of the samples of the specified band.
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/java/awt/image/SampleModel.html