Returns data for a single pixel in a primitive array of type TransferType. For a
MultiPixelPackedSampleModel
, the array has one element, and the type is the smallest of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or DataBuffer.TYPE_INT that can hold a single pixel. Generally,
obj
should be passed in as
null
, so that the
Object
is created automatically and is the correct primitive data type.
The following code illustrates transferring data for one pixel from DataBuffer db1
, whose storage layout is described by MultiPixelPackedSampleModel
mppsm1
, to DataBuffer db2
, whose storage layout is described by MultiPixelPackedSampleModel mppsm2
. The transfer is generally more efficient than using getPixel
or setPixel
.
MultiPixelPackedSampleModel mppsm1, mppsm2;
DataBufferInt db1, db2;
mppsm2.setDataElements(x, y, mppsm1.getDataElements(x, y, null,
db1), db2);
Using
getDataElements
or
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 not null
, it should be a primitive array of type TransferType. Otherwise, a ClassCastException
is thrown. An ArrayIndexOutOfBoundsException
is thrown if the coordinates are not in bounds, or if obj
is not null
and is not large enough to hold the pixel data.