MultiPixelPackedSampleModel
class represents one-banded images and can pack multiple one-sample pixels into one data element. Pixels are not allowed to span data elements. The data type can be DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or DataBuffer.TYPE_INT. Each pixel must be a power of 2 number of bits and a power of 2 number of pixels must fit exactly in one data element. Pixel bit stride is equal to the number of bits per pixel. Scanline stride is in data elements and the last several data elements might be padded with unused pixels. Data bit offset is the offset in bits from the beginning of the {@link DataBuffer} to the first pixel and must bea multiple of pixel bit stride. The following code illustrates extracting the bits for pixel x, y
from DataBuffer
data
and storing the pixel data in data elements of type dataType
:
int dataElementSize = DataBuffer.getDataTypeSize(dataType); int bitnum = dataBitOffset + x*pixelBitStride; int element = data.getElem(y*scanlineStride + bitnum/dataElementSize); int shift = dataElementSize - (bitnum & (dataElementSize-1)) - pixelBitStride; int pixel = (element >> shift) & ((1 << pixelBitStride) - 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|