Returns data for a single pixel in a primitive array of type TransferType. For a SinglePixelPackedSampleModel, the array will have one element, and the type will be the same as the storage data type. 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 SinglePixelPackedSampleModel sppsm1
, to DataBuffer db2
, whose storage layout is described by SinglePixelPackedSampleModel sppsm2
. The transfer will generally be more efficient than using getPixel/setPixel.
SinglePixelPackedSampleModel sppsm1, sppsm2;
DataBufferInt db1, db2;
sppsm2.setDataElements(x, y, sppsm1.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.