public abstract class SampleModel extends Object
Modifier and Type | Field and Description |
---|---|
protected int |
dataType
The DataBuffer type that is used to store the data of the image
described.
|
protected int |
height
Height of image described.
|
protected int |
numBands
Number of bands in the image described.
|
protected int |
width
Width of image described.
|
Constructor and Description |
---|
SampleModel(int dataType,
int w,
int h,
int numBands)
Creates a new sample model with the specified attributes.
|
Modifier and Type | Method and Description |
---|---|
abstract SampleModel |
createCompatibleSampleModel(int w,
int h)
Creates a new
SampleModel that is compatible with this
model and has the specified width and height. |
abstract DataBuffer |
createDataBuffer()
Creates a new
DataBuffer of the correct type and size for this
SampleModel . |
abstract SampleModel |
createSubsetSampleModel(int[] bands)
Return a SampleModel with a subset of the bands in this model.
|
Object |
getDataElements(int x,
int y,
int w,
int h,
Object obj,
DataBuffer data) |
abstract Object |
getDataElements(int x,
int y,
Object obj,
DataBuffer data)
This method is provided as a faster alternative to getPixel(),
that can be used when there is no need to decode the pixel into
separate sample values.
|
int |
getDataType()
Returns the type of the
DataBuffer that this
SampleModel accesses. |
int |
getHeight()
Returns the height of the pixel data accessible via this
SampleModel . |
int |
getNumBands()
Returns the number of bands for this
SampleModel . |
abstract int |
getNumDataElements() |
double[] |
getPixel(int x,
int y,
double[] dArray,
DataBuffer data)
Returns an array containing the samples for the pixel at (x, y) in the
specified data buffer.
|
float[] |
getPixel(int x,
int y,
float[] fArray,
DataBuffer data)
Returns an array containing the samples for the pixel at (x, y) in the
specified data buffer.
|
int[] |
getPixel(int x,
int y,
int[] iArray,
DataBuffer data)
Returns an array containing the samples for the pixel at (x, y) in the
specified data buffer.
|
double[] |
getPixels(int x,
int y,
int w,
int h,
double[] dArray,
DataBuffer data)
Returns an array containing the samples for the pixels in the region
specified by (x, y, w, h) in the specified data buffer.
|
float[] |
getPixels(int x,
int y,
int w,
int h,
float[] fArray,
DataBuffer data)
Returns an array containing the samples for the pixels in the region
specified by (x, y, w, h) in the specified data buffer.
|
int[] |
getPixels(int x,
int y,
int w,
int h,
int[] iArray,
DataBuffer data)
Returns an array containing the samples for the pixels in the region
specified by (x, y, w, h) in the specified data buffer.
|
abstract int |
getSample(int x,
int y,
int b,
DataBuffer data)
Returns the sample value for the pixel at (x, y) in the specified data
buffer.
|
double |
getSampleDouble(int x,
int y,
int b,
DataBuffer data)
Returns the sample value for the pixel at (x, y) in the specified data
buffer.
|
float |
getSampleFloat(int x,
int y,
int b,
DataBuffer data)
Returns the sample value for the pixel at (x, y) in the specified data
buffer.
|
double[] |
getSamples(int x,
int y,
int w,
int h,
int b,
double[] dArray,
DataBuffer data)
Returns an array containing the samples from one band for the pixels in
the region specified by (x, y, w, h) in the specified data buffer.
|
float[] |
getSamples(int x,
int y,
int w,
int h,
int b,
float[] fArray,
DataBuffer data)
Returns an array containing the samples from one band for the pixels in
the region specified by (x, y, w, h) in the specified data buffer.
|
int[] |
getSamples(int x,
int y,
int w,
int h,
int b,
int[] iArray,
DataBuffer data)
Returns an array containing the samples from one band for the pixels in
the region specified by (x, y, w, h) in the specified data buffer.
|
abstract int[] |
getSampleSize()
Returns an array containing the size (in bits) for each band accessed by
the
SampleModel . |
abstract int |
getSampleSize(int band)
Returns the size (in bits) of the samples for the specified band.
|
int |
getTransferType() |
int |
getWidth()
Returns the width of the pixel data accessible via this
SampleModel . |
void |
setDataElements(int x,
int y,
int w,
int h,
Object obj,
DataBuffer data) |
abstract void |
setDataElements(int x,
int y,
Object obj,
DataBuffer data) |
void |
setPixel(int x,
int y,
double[] dArray,
DataBuffer data)
Sets the samples for the pixel at (x, y) in the specified data buffer to
the specified values.
|
void |
setPixel(int x,
int y,
float[] fArray,
DataBuffer data)
Sets the samples for the pixel at (x, y) in the specified data buffer to
the specified values.
|
void |
setPixel(int x,
int y,
int[] iArray,
DataBuffer data)
Sets the samples for the pixel at (x, y) in the specified data buffer to
the specified values.
|
void |
setPixels(int x,
int y,
int w,
int h,
double[] dArray,
DataBuffer data)
Sets the sample values for the pixels in the region specified by
(x, y, w, h) in the specified data buffer.
|
void |
setPixels(int x,
int y,
int w,
int h,
float[] fArray,
DataBuffer data)
Sets the sample values for the pixels in the region specified by
(x, y, w, h) in the specified data buffer.
|
void |
setPixels(int x,
int y,
int w,
int h,
int[] iArray,
DataBuffer data)
Sets the sample values for the pixels in the region specified by
(x, y, w, h) in the specified data buffer.
|
void |
setSample(int x,
int y,
int b,
double s,
DataBuffer data)
Sets the sample value for a band for the pixel at (x, y) in the
specified data buffer.
|
void |
setSample(int x,
int y,
int b,
float s,
DataBuffer data)
Sets the sample value for a band for the pixel at (x, y) in the
specified data buffer.
|
abstract void |
setSample(int x,
int y,
int b,
int s,
DataBuffer data)
Sets the sample value for a band for the pixel at (x, y) in the
specified data buffer.
|
void |
setSamples(int x,
int y,
int w,
int h,
int b,
double[] dArray,
DataBuffer data)
Sets the sample values for one band for the pixels in the region
specified by (x, y, w, h) in the specified data buffer.
|
void |
setSamples(int x,
int y,
int w,
int h,
int b,
float[] fArray,
DataBuffer data)
Sets the sample values for one band for the pixels in the region
specified by (x, y, w, h) in the specified data buffer.
|
void |
setSamples(int x,
int y,
int w,
int h,
int b,
int[] iArray,
DataBuffer data)
Sets the sample values for one band for the pixels in the region
specified by (x, y, w, h) in the specified data buffer.
|
protected int width
protected int height
protected int numBands
protected int dataType
public SampleModel(int dataType, int w, int h, int numBands)
dataType
- the data type (one of DataBuffer.TYPE_BYTE
,
DataBuffer.TYPE_USHORT
, DataBuffer.TYPE_SHORT
,
DataBuffer.TYPE_INT
, DataBuffer.TYPE_FLOAT
,
DataBuffer.TYPE_DOUBLE
or DataBuffer.TYPE_UNDEFINED
).w
- the width in pixels (must be greater than zero).h
- the height in pixels (must be greater than zero).numBands
- the number of bands (must be greater than zero).IllegalArgumentException
- if dataType
is not one of
the listed values.IllegalArgumentException
- if w
is less than or equal
to zero.IllegalArgumentException
- if h
is less than or equal
to zero.IllegalArgumentException
- if w * h
is greater than
Integer.MAX_VALUE
.public final int getWidth()
SampleModel
.getHeight()
public final int getHeight()
SampleModel
.getWidth()
public final int getNumBands()
SampleModel
.public abstract int getNumDataElements()
public final int getDataType()
DataBuffer
that this
SampleModel
accesses.public int getTransferType()
public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
iArray
is not null
,
it will be populated with the sample values and returned as the result of
this function (this avoids allocating a new array instance).x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.iArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).data
- the data buffer (null
not permitted).NullPointerException
- if data
is null
.public abstract Object getDataElements(int x, int y, Object obj, DataBuffer data)
obj
- An array to return the pixel data in. If null, an
array of the right type and size will be created.public Object getDataElements(int x, int y, int w, int h, Object obj, DataBuffer data)
public abstract void setDataElements(int x, int y, Object obj, DataBuffer data)
public void setDataElements(int x, int y, int w, int h, Object obj, DataBuffer data)
public float[] getPixel(int x, int y, float[] fArray, DataBuffer data)
fArray
is not null
,
it will be populated with the sample values and returned as the result of
this function (this avoids allocating a new array instance).x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.fArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).data
- the data buffer (null
not permitted).NullPointerException
- if data
is null
.public double[] getPixel(int x, int y, double[] dArray, DataBuffer data)
dArray
is not null
,
it will be populated with the sample values and returned as the result of
this function (this avoids allocating a new array instance).x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.dArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).data
- the data buffer (null
not permitted).NullPointerException
- if data
is null
.public int[] getPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
iArray
is not null
, it will be
populated with the sample values and returned as the result of this
function (this avoids allocating a new array instance).x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.iArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).data
- the data buffer (null
not permitted).NullPointerException
- if data
is null
.public float[] getPixels(int x, int y, int w, int h, float[] fArray, DataBuffer data)
fArray
is not null
, it will be
populated with the sample values and returned as the result of this
function (this avoids allocating a new array instance).x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.fArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).data
- the data buffer (null
not permitted).NullPointerException
- if data
is null
.public double[] getPixels(int x, int y, int w, int h, double[] dArray, DataBuffer data)
dArray
is not null
, it will be
populated with the sample values and returned as the result of this
function (this avoids allocating a new array instance).x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.dArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).data
- the data buffer (null
not permitted).NullPointerException
- if data
is null
.public abstract int getSample(int x, int y, int b, DataBuffer data)
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.b
- the band (in the range 0
to
getNumBands() - 1
).data
- the data buffer (null
not permitted).NullPointerException
- if data
is null
.public float getSampleFloat(int x, int y, int b, DataBuffer data)
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.b
- the band (in the range 0
to
getNumBands() - 1
).data
- the data buffer (null
not permitted).NullPointerException
- if data
is null
.getSample(int, int, int, DataBuffer)
public double getSampleDouble(int x, int y, int b, DataBuffer data)
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.b
- the band (in the range 0
to
getNumBands() - 1
).data
- the data buffer (null
not permitted).NullPointerException
- if data
is null
.getSample(int, int, int, DataBuffer)
public int[] getSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
iArray
is not null
, it will be
populated with the sample values and returned as the result of this
function (this avoids allocating a new array instance).x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.b
- the band (in the range 0
to
getNumBands() - 1).iArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).data
- the data buffer (null
not permitted).NullPointerException
- if data
is null
.public float[] getSamples(int x, int y, int w, int h, int b, float[] fArray, DataBuffer data)
fArray
is not null
, it will be
populated with the sample values and returned as the result of this
function (this avoids allocating a new array instance).x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.b
- the band (in the range 0
to
getNumBands() - 1).fArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).data
- the data buffer (null
not permitted).NullPointerException
- if data
is null
.public double[] getSamples(int x, int y, int w, int h, int b, double[] dArray, DataBuffer data)
dArray
is not null
, it will be
populated with the sample values and returned as the result of this
function (this avoids allocating a new array instance).x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.b
- the band (in the range 0
to
getNumBands() - 1).dArray
- an array to populate with the sample values and return as
the result (if null
, a new array will be allocated).data
- the data buffer (null
not permitted).NullPointerException
- if data
is null
.public void setPixel(int x, int y, int[] iArray, DataBuffer data)
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.iArray
- the sample values (null
not permitted).data
- the data buffer (null
not permitted).NullPointerException
- if either iArray
or
data
is null
.public void setPixel(int x, int y, float[] fArray, DataBuffer data)
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.fArray
- the sample values (null
not permitted).data
- the data buffer (null
not permitted).NullPointerException
- if either fArray
or
data
is null
.public void setPixel(int x, int y, double[] dArray, DataBuffer data)
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.dArray
- the sample values (null
not permitted).data
- the data buffer (null
not permitted).NullPointerException
- if either dArray
or
data
is null
.public void setPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.iArray
- the pixel sample values (null
not permitted).data
- the data buffer (null
not permitted).NullPointerException
- if either iArray
or
data
is null
.public void setPixels(int x, int y, int w, int h, float[] fArray, DataBuffer data)
x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.fArray
- the pixel sample values (null
not permitted).data
- the data buffer (null
not permitted).NullPointerException
- if either fArray
or
data
is null
.public void setPixels(int x, int y, int w, int h, double[] dArray, DataBuffer data)
x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.dArray
- the pixel sample values (null
not permitted).data
- the data buffer (null
not permitted).NullPointerException
- if either dArray
or
data
is null
.public abstract void setSample(int x, int y, int b, int s, DataBuffer data)
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.b
- the band (in the range 0
to
getNumBands() - 1
).s
- the sample value.data
- the data buffer (null
not permitted).NullPointerException
- if data
is null
.public void setSample(int x, int y, int b, float s, DataBuffer data)
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.b
- the band (in the range 0
to
getNumBands() - 1
).s
- the sample value.data
- the data buffer (null
not permitted).NullPointerException
- if data
is null
.public void setSample(int x, int y, int b, double s, DataBuffer data)
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.b
- the band (in the range 0
to
getNumBands() - 1
).s
- the sample value.data
- the data buffer (null
not permitted).NullPointerException
- if data
is null
.public void setSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.b
- the band (in the range 0
to
getNumBands() - 1).iArray
- the sample values (null
not permitted).data
- the data buffer (null
not permitted).NullPointerException
- if either iArray
or
data
is null
.public void setSamples(int x, int y, int w, int h, int b, float[] fArray, DataBuffer data)
x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.b
- the band (in the range 0
to
getNumBands() - 1).fArray
- the sample values (null
not permitted).data
- the data buffer (null
not permitted).NullPointerException
- if either iArray
or
data
is null
.public void setSamples(int x, int y, int w, int h, int b, double[] dArray, DataBuffer data)
x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.b
- the band (in the range 0
to
getNumBands() - 1).dArray
- the sample values (null
not permitted).data
- the data buffer (null
not permitted).NullPointerException
- if either iArray
or
data
is null
.public abstract SampleModel createCompatibleSampleModel(int w, int h)
SampleModel
that is compatible with this
model and has the specified width and height.w
- the width (in pixels).h
- the height (in pixels).public abstract SampleModel createSubsetSampleModel(int[] bands)
bands
- Array with band indices to include.public abstract DataBuffer createDataBuffer()
DataBuffer
of the correct type and size for this
SampleModel
.public abstract int[] getSampleSize()
SampleModel
.getSampleSize(int)
public abstract int getSampleSize(int band)
band
- the band (in the range 0
to
getNumBands() - 1
).