SampleModelpublic abstract class SampleModel extends Object 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. |
Fields Summary |
---|
protected int | widthWidth in pixels of the region of image data that this SampleModel
describes. | protected int | heightHeight in pixels of the region of image data that this SampleModel
describes. | protected int | numBandsNumber of bands of the image data that this SampleModel describes. | protected int | dataTypeData type of the DataBuffer storing the pixel data. |
Constructors Summary |
---|
public SampleModel(int dataType, int w, int h, int numBands)Constructs a SampleModel with the specified parameters.
ColorModel.loadLibraries();
initIDs();
float size = (float)w*h;
if (w <= 0 || h <= 0) {
throw new IllegalArgumentException("Width ("+w+") and height ("+
h+") must be > 0");
}
if (size >= Integer.MAX_VALUE) {
throw new IllegalArgumentException("Dimensions (width="+w+
" height="+h+") are too large");
}
if (dataType < DataBuffer.TYPE_BYTE ||
(dataType > DataBuffer.TYPE_DOUBLE &&
dataType != DataBuffer.TYPE_UNDEFINED))
{
throw new IllegalArgumentException("Unsupported dataType: "+
dataType);
}
if (numBands <= 0) {
throw new IllegalArgumentException("Number of bands must be > 0");
}
this.dataType = dataType;
this.width = w;
this.height = h;
this.numBands = numBands;
|
Methods Summary |
---|
public abstract java.awt.image.SampleModel | createCompatibleSampleModel(int w, int h)Creates a SampleModel which describes data in this SampleModel's
format, but with a different width and height.
| public abstract java.awt.image.DataBuffer | createDataBuffer()Creates a DataBuffer that corresponds to this SampleModel.
The DataBuffer's width and height will match this SampleModel's.
| public abstract java.awt.image.SampleModel | createSubsetSampleModel(int[] bands)Creates a new SampleModel
with a subset of the bands of this
SampleModel.
| public abstract java.lang.Object | getDataElements(int x, int y, java.lang.Object obj, java.awt.image.DataBuffer data)Returns data for a single pixel in a primitive array of type
TransferType. For image data supported by the Java 2D API, this
will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT,
DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT,
or DataBuffer.TYPE_DOUBLE. Data may be returned in a 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.
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.
| public java.lang.Object | getDataElements(int x, int y, int w, int h, java.lang.Object obj, java.awt.image.DataBuffer data)Returns the pixel data for the specified rectangle of pixels in a
primitive array of type TransferType.
For image data supported by the Java 2D API, this
will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT,
DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT,
or DataBuffer.TYPE_DOUBLE. Data may be returned in a 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.
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.
int type = getTransferType();
int numDataElems = getNumDataElements();
int cnt = 0;
Object o = null;
switch(type) {
case DataBuffer.TYPE_BYTE:
byte[] btemp;
byte[] bdata;
if (obj == null)
bdata = new byte[numDataElems*w*h];
else
bdata = (byte[])obj;
for (int i=y; i<y+h; i++) {
for (int j=x; j<x+w; j++) {
o = getDataElements(j, i, o, data);
btemp = (byte[])o;
for (int k=0; k<numDataElems; k++) {
bdata[cnt++] = btemp[k];
}
}
}
obj = (Object)bdata;
break;
case DataBuffer.TYPE_USHORT:
case DataBuffer.TYPE_SHORT:
short[] sdata;
short[] stemp;
if (obj == null)
sdata = new short[numDataElems*w*h];
else
sdata = (short[])obj;
for (int i=y; i<y+h; i++) {
for (int j=x; j<x+w; j++) {
o = getDataElements(j, i, o, data);
stemp = (short[])o;
for (int k=0; k<numDataElems; k++) {
sdata[cnt++] = stemp[k];
}
}
}
obj = (Object)sdata;
break;
case DataBuffer.TYPE_INT:
int[] idata;
int[] itemp;
if (obj == null)
idata = new int[numDataElems*w*h];
else
idata = (int[])obj;
for (int i=y; i<y+h; i++) {
for (int j=x; j<x+w; j++) {
o = getDataElements(j, i, o, data);
itemp = (int[])o;
for (int k=0; k<numDataElems; k++) {
idata[cnt++] = itemp[k];
}
}
}
obj = (Object)idata;
break;
case DataBuffer.TYPE_FLOAT:
float[] fdata;
float[] ftemp;
if (obj == null)
fdata = new float[numDataElems*w*h];
else
fdata = (float[])obj;
for (int i=y; i<y+h; i++) {
for (int j=x; j<x+w; j++) {
o = getDataElements(j, i, o, data);
ftemp = (float[])o;
for (int k=0; k<numDataElems; k++) {
fdata[cnt++] = ftemp[k];
}
}
}
obj = (Object)fdata;
break;
case DataBuffer.TYPE_DOUBLE:
double[] ddata;
double[] dtemp;
if (obj == null)
ddata = new double[numDataElems*w*h];
else
ddata = (double[])obj;
for (int i=y; i<y+h; i++) {
for (int j=x; j<x+w; j++) {
o = getDataElements(j, i, o, data);
dtemp = (double[])o;
for (int k=0; k<numDataElems; k++) {
ddata[cnt++] = dtemp[k];
}
}
}
obj = (Object)ddata;
break;
}
return obj;
| public final int | getDataType()Returns the data type of the DataBuffer storing the pixel data.
return dataType;
| public final int | getHeight()Returns the height in pixels.
return height;
| public final int | getNumBands()Returns the total number of bands of image data.
return numBands;
| public abstract int | getNumDataElements()Returns the number of data elements needed to transfer a pixel
via the getDataElements and setDataElements methods. When pixels
are transferred via these methods, they may be transferred in a
packed or unpacked format, depending on the implementation of the
SampleModel. Using these methods, pixels are transferred as an
array of getNumDataElements() elements of a primitive type given
by getTransferType(). The TransferType may or may not be the same
as the storage DataType.
| public float[] | getPixel(int x, int y, float[] fArray, java.awt.image.DataBuffer data)Returns the samples for the specified pixel in an array of float.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
float pixels[];
if (fArray != null)
pixels = fArray;
else
pixels = new float[numBands];
for (int i=0; i<numBands; i++)
pixels[i] = getSampleFloat(x, y, i, data);
return pixels;
| public double[] | getPixel(int x, int y, double[] dArray, java.awt.image.DataBuffer data)Returns the samples for the specified pixel in an array of double.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
double pixels[];
if(dArray != null)
pixels = dArray;
else
pixels = new double[numBands];
for (int i=0; i<numBands; i++)
pixels[i] = getSampleDouble(x, y, i, data);
return pixels;
| public int[] | getPixel(int x, int y, int[] iArray, java.awt.image.DataBuffer data)Returns the samples for a specified pixel in an int array,
one sample per array element.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
int pixels[];
if (iArray != null)
pixels = iArray;
else
pixels = new int[numBands];
for (int i=0; i<numBands; i++) {
pixels[i] = getSample(x, y, i, data);
}
return pixels;
| public int[] | getPixels(int x, int y, int w, int h, int[] iArray, java.awt.image.DataBuffer data)Returns all samples for a rectangle of pixels in an
int array, one sample per array element.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
int pixels[];
int Offset=0;
if (iArray != null)
pixels = iArray;
else
pixels = new int[numBands * w * h];
for (int i=y; i<(h+y); i++) {
for (int j=x; j<(w+x); j++) {
for(int k=0; k<numBands; k++) {
pixels[Offset++] = getSample(j, i, k, data);
}
}
}
return pixels;
| public float[] | getPixels(int x, int y, int w, int h, float[] fArray, java.awt.image.DataBuffer data)Returns all samples for a rectangle of pixels in a float
array, one sample per array element.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
float pixels[];
int Offset = 0;
if (fArray != null)
pixels = fArray;
else
pixels = new float[numBands * w * h];
for (int i=y; i<(h+y); i++) {
for(int j=x; j<(w+x); j++) {
for(int k=0; k<numBands; k++) {
pixels[Offset++] = getSampleFloat(j, i, k, data);
}
}
}
return pixels;
| public double[] | getPixels(int x, int y, int w, int h, double[] dArray, java.awt.image.DataBuffer data)Returns all samples for a rectangle of pixels in a double
array, one sample per array element.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
double pixels[];
int Offset = 0;
if (dArray != null)
pixels = dArray;
else
pixels = new double[numBands * w * h];
// Fix 4217412
for (int i=y; i<(h+y); i++) {
for (int j=x; j<(w+x); j++) {
for (int k=0; k<numBands; k++) {
pixels[Offset++] = getSampleDouble(j, i, k, data);
}
}
}
return pixels;
| public abstract int | getSample(int x, int y, int b, java.awt.image.DataBuffer data)Returns the sample in a specified band for the pixel located
at (x,y) as an int.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
| public double | getSampleDouble(int x, int y, int b, java.awt.image.DataBuffer data)Returns the sample in a specified band
for a pixel located at (x,y) as a double.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
double sample;
sample = (double) getSample(x, y, b, data);
return sample;
| public float | getSampleFloat(int x, int y, int b, java.awt.image.DataBuffer data)Returns the sample in a specified band
for the pixel located at (x,y) as a float.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
float sample;
sample = (float) getSample(x, y, b, data);
return sample;
| public abstract int[] | getSampleSize()Returns the size in bits of samples for all bands.
| public abstract int | getSampleSize(int band)Returns the size in bits of samples for the specified band.
| public int[] | getSamples(int x, int y, int w, int h, int b, int[] iArray, java.awt.image.DataBuffer data)Returns the samples for a specified band for the specified rectangle
of pixels in an int array, one sample per array element.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
int pixels[];
int Offset=0;
if (iArray != null)
pixels = iArray;
else
pixels = new int[w * h];
for(int i=y; i<(h+y); i++) {
for (int j=x; j<(w+x); j++) {
pixels[Offset++] = getSample(j, i, b, data);
}
}
return pixels;
| public float[] | getSamples(int x, int y, int w, int h, int b, float[] fArray, java.awt.image.DataBuffer data)Returns the samples for a specified band for the specified rectangle
of pixels in a float array, one sample per array element.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
float pixels[];
int Offset=0;
if (fArray != null)
pixels = fArray;
else
pixels = new float[w * h];
for (int i=y; i<(h+y); i++) {
for (int j=x; j<(w+x); j++) {
pixels[Offset++] = getSampleFloat(j, i, b, data);
}
}
return pixels;
| public double[] | getSamples(int x, int y, int w, int h, int b, double[] dArray, java.awt.image.DataBuffer data)Returns the samples for a specified band for a specified rectangle
of pixels in a double array, one sample per array element.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
double pixels[];
int Offset=0;
if (dArray != null)
pixels = dArray;
else
pixels = new double[w * h];
for (int i=y; i<(y+h); i++) {
for (int j=x; j<(x+w); j++) {
pixels[Offset++] = getSampleDouble(j, i, b, data);
}
}
return pixels;
| public int | getTransferType()Returns the TransferType used to transfer pixels via the
getDataElements and setDataElements methods. When pixels
are transferred via these methods, they may be transferred in a
packed or unpacked format, depending on the implementation of the
SampleModel. Using these methods, pixels are transferred as an
array of getNumDataElements() elements of a primitive type given
by getTransferType(). The TransferType may or may not be the same
as the storage DataType. The TransferType will be one of the types
defined in DataBuffer.
return dataType;
| public final int | getWidth()Returns the width in pixels.
return width;
| private static native void | initIDs()
| public abstract void | setDataElements(int x, int y, java.lang.Object obj, java.awt.image.DataBuffer data)Sets the data for a single pixel in the specified DataBuffer from a
primitive array of type TransferType. For image data supported by
the Java 2D API, this will be one of DataBuffer.TYPE_BYTE,
DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT,
DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE. Data in the array
may be in a packed format, thus increasing efficiency for data
transfers.
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.
| public void | setDataElements(int x, int y, int w, int h, java.lang.Object obj, java.awt.image.DataBuffer data)Sets the data for a rectangle of pixels in the specified DataBuffer
from a primitive array of type TransferType. For image data supported
by the Java 2D API, this will be one of DataBuffer.TYPE_BYTE,
DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT,
DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE. Data in the array
may be in a packed format, thus increasing efficiency for data
transfers.
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.
int cnt = 0;
Object o = null;
int type = getTransferType();
int numDataElems = getNumDataElements();
switch(type) {
case DataBuffer.TYPE_BYTE:
byte[] barray = (byte[])obj;
byte[] btemp = new byte[numDataElems];
for (int i=y; i<y+h; i++) {
for (int j=x; j<x+w; j++) {
for (int k=0; k<numDataElems; k++) {
btemp[k] = barray[cnt++];
}
setDataElements(j, i, btemp, data);
}
}
break;
case DataBuffer.TYPE_USHORT:
case DataBuffer.TYPE_SHORT:
short[] sarray = (short[])obj;
short[] stemp = new short[numDataElems];
for (int i=y; i<y+h; i++) {
for (int j=x; j<x+w; j++) {
for (int k=0; k<numDataElems; k++) {
stemp[k] = sarray[cnt++];
}
setDataElements(j, i, stemp, data);
}
}
break;
case DataBuffer.TYPE_INT:
int[] iArray = (int[])obj;
int[] itemp = new int[numDataElems];
for (int i=y; i<y+h; i++) {
for (int j=x; j<x+w; j++) {
for (int k=0; k<numDataElems; k++) {
itemp[k] = iArray[cnt++];
}
setDataElements(j, i, itemp, data);
}
}
break;
case DataBuffer.TYPE_FLOAT:
float[] fArray = (float[])obj;
float[] ftemp = new float[numDataElems];
for (int i=y; i<y+h; i++) {
for (int j=x; j<x+w; j++) {
for (int k=0; k<numDataElems; k++) {
ftemp[k] = fArray[cnt++];
}
setDataElements(j, i, ftemp, data);
}
}
break;
case DataBuffer.TYPE_DOUBLE:
double[] dArray = (double[])obj;
double[] dtemp = new double[numDataElems];
for (int i=y; i<y+h; i++) {
for (int j=x; j<x+w; j++) {
for (int k=0; k<numDataElems; k++) {
dtemp[k] = dArray[cnt++];
}
setDataElements(j, i, dtemp, data);
}
}
break;
}
| public void | setPixel(int x, int y, int[] iArray, java.awt.image.DataBuffer data)Sets a pixel in the DataBuffer using an int array of samples for input.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
for (int i=0; i<numBands; i++)
setSample(x, y, i, iArray[i], data);
| public void | setPixel(int x, int y, float[] fArray, java.awt.image.DataBuffer data)Sets a pixel in the DataBuffer using a float array of samples for input.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
for (int i=0; i<numBands; i++)
setSample(x, y, i, fArray[i], data);
| public void | setPixel(int x, int y, double[] dArray, java.awt.image.DataBuffer data)Sets a pixel in the DataBuffer using a double array of samples
for input.
for (int i=0; i<numBands; i++)
setSample(x, y, i, dArray[i], data);
| public void | setPixels(int x, int y, int w, int h, int[] iArray, java.awt.image.DataBuffer data)Sets all samples for a rectangle of pixels from an int array containing
one sample per array element.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
int Offset=0;
for (int i=y; i<(y+h); i++) {
for (int j=x; j<(x+w); j++) {
for (int k=0; k<numBands; k++) {
setSample(j, i, k, iArray[Offset++], data);
}
}
}
| public void | setPixels(int x, int y, int w, int h, float[] fArray, java.awt.image.DataBuffer data)Sets all samples for a rectangle of pixels from a float array containing
one sample per array element.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
int Offset=0;
for (int i=y; i<(y+h); i++) {
for (int j=x; j<(x+w); j++) {
for(int k=0; k<numBands; k++) {
setSample(j, i, k, fArray[Offset++], data);
}
}
}
| public void | setPixels(int x, int y, int w, int h, double[] dArray, java.awt.image.DataBuffer data)Sets all samples for a rectangle of pixels from a double array
containing one sample per array element.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
int Offset=0;
for (int i=y; i<(y+h); i++) {
for (int j=x; j<(x+w); j++) {
for (int k=0; k<numBands; k++) {
setSample(j, i, k, dArray[Offset++], data);
}
}
}
| public abstract void | setSample(int x, int y, int b, int s, java.awt.image.DataBuffer data)Sets a sample in the specified band for the pixel located at (x,y)
in the DataBuffer using an int for input.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
| public void | setSample(int x, int y, int b, float s, java.awt.image.DataBuffer data)Sets a sample in the specified band for the pixel located at (x,y)
in the DataBuffer using a float for input.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
int sample = (int)s;
setSample(x, y, b, sample, data);
| public void | setSample(int x, int y, int b, double s, java.awt.image.DataBuffer data)Sets a sample in the specified band for the pixel located at (x,y)
in the DataBuffer using a double for input.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
int sample = (int)s;
setSample(x, y, b, sample, data);
| public void | setSamples(int x, int y, int w, int h, int b, int[] iArray, java.awt.image.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.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
int Offset=0;
for (int i=y; i<(y+h); i++) {
for (int j=x; j<(x+w); j++) {
setSample(j, i, b, iArray[Offset++], data);
}
}
| public void | setSamples(int x, int y, int w, int h, int b, float[] fArray, java.awt.image.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.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
int Offset=0;
for (int i=y; i<(y+h); i++) {
for (int j=x; j<(x+w); j++) {
setSample(j, i, b, fArray[Offset++], data);
}
}
| public void | setSamples(int x, int y, int w, int h, int b, double[] dArray, java.awt.image.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.
ArrayIndexOutOfBoundsException may be thrown if the coordinates are
not in bounds.
int Offset=0;
for (int i=y; i<(y+h); i++) {
for (int j=x; j<(x+w); j++) {
setSample(j, i, b, dArray[Offset++], data);
}
}
|
|