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 DataBuffer to the first pixel and must be
a 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);
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int | bitMask
Bitmask that extracts the rightmost pixel of a data element. |
| pack-priv int | dataBitOffset
The bit offset into the data array where the first pixel begins. |
| pack-priv int | dataElementSize
The size of a data element in bits. |
| pack-priv int | pixelBitStride
The number of bits from one pixel to the next. |
| pack-priv int | pixelsPerDataElement
The number of pixels that fit in a data element. |
| pack-priv int | scanlineStride
ScanlineStride of the data buffer described in data array elements. |
| Access | Constructor and Description |
|---|---|
| public | MultiPixelPackedSampleModel(int
the data type for storing samples dataType, int the width, in pixels, of the region of
image data described w, int the height, in pixels, of the region of
image data described h, int the number of bits per pixel numberOfBits)Constructs a |
| public | MultiPixelPackedSampleModel(int
the data type for storing samples dataType, int the width, in pixels, of the region of
image data described w, int the height, in pixels, of the region of
image data described h, int the number of bits per pixel numberOfBits, int the line stride of the image data scanlineStride, int the data bit offset for the region of image
data described dataBitOffset)Constructs a |
| Modifier and Type | Method and Description |
|---|---|
| public SampleModel | Returns: aSampleModel with the specified width and height
and with the same storage data type and number of bits per pixel
as this MultiPixelPackedSampleModel.the specified width w, int the specified height h)Implements abstract java. Creates a new |
| public DataBuffer | Returns: aDataBuffer with the same data type and
size as this MultiPixelPackedSampleModel.Implements abstract java. Creates a |
| public SampleModel | Returns: a newSampleModel with the same bands as
this MultiPixelPackedSampleModel.the specified bands (ignored) bands)Implements abstract java. Creates a new |
| public boolean | equals(Object o)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public int | Returns: the bit offset of the specified pixel.the specified pixel x)Returns the offset, in bits, into the data element in which it is
stored for the |
| public int | Returns: thedataBitOffset of this
MultiPixelPackedSampleModel.Returns the data bit offset in bits. |
| public Object | Returns: anObject containing data for the specified
pixel.the X coordinate of the specified pixel x, int the Y coordinate of the specified pixel y, Object a primitive array in which to return the pixel data or
obj, DataBuffer null.the data)DataBuffer containing the image data.Implements abstract java. Returns data for a single pixel in a primitive array of type TransferType. |
| public int | Returns: the number of data elements.Implements abstract java. Returns the number of data elements needed to transfer one pixel
via the |
| public int | Returns: the offset of the specified pixel.the X coordinate of the specified pixel x, int the Y coordinate of the specified pixel y)Returns the offset of pixel (x, y) in data array elements. |
| public int[] | Returns: an array containing the specified pixel.the X coordinate of the specified pixel x, int the Y coordinate of the specified pixel y, int[] the array containing the pixel to be returned or
iArray, DataBuffer nullthe data)DataBuffer where image data is storedOverrides java. Returns the specified single band pixel in the first element
of an |
| public int | Returns: thepixelBitStride of this
MultiPixelPackedSampleModel.Returns the pixel bit stride in bits. |
| public int | Returns: the specified band containing the sample of the specified pixel.the X coordinate of the specified pixel x, int the Y coordinate of the specified pixel y, int the band to return, which must be 0 b, DataBuffer the data)DataBuffer containing the image
dataImplements abstract java. Returns as |
| public int[] | Returns: the number of bits per sample.Implements abstract java. Returns the number of bits per sample for all bands. |
| public int | Returns: the number of bits per sample for the specified band.the specified band (ignored) band)Implements abstract java. Returns the number of bits per sample for the specified band. |
| public int | Returns: the scanline stride of thisMultiPixelPackedSampleModel.Returns the scanline stride. |
| public int | Returns: the transfertype.Overrides java. Returns the TransferType used to transfer pixels by way of the
|
| public int | |
| public void | setDataElements(int
the X coordinate of the pixel location x, int the Y coordinate of the pixel location y, Object a primitive array containing pixel data obj, DataBuffer the data)DataBuffer containing the image dataImplements abstract java. Sets the data for a single pixel in the specified
|
| public void | setPixel(int
the X coordinate of the pixel location x, int the Y coordinate of the pixel location y, int[] the input pixel in an iArray, DataBuffer int arraythe data)DataBuffer containing the image dataOverrides java. Sets a pixel in the |
| public void | setSample(int
the X coordinate of the specified pixel x, int the Y coordinate of the specified pixel y, int the band to set, which must be 0 b, int the input sample as an s, DataBuffer intthe data)DataBuffer where image data is storedImplements abstract java. Sets a sample in the specified band for the pixel located at
(x, y) in the |
| bitMask | back to summary |
|---|---|
| pack-priv int bitMask Bitmask that extracts the rightmost pixel of a data element. | |
| dataBitOffset | back to summary |
|---|---|
| pack-priv int dataBitOffset The bit offset into the data array where the first pixel begins. | |
| dataElementSize | back to summary |
|---|---|
| pack-priv int dataElementSize The size of a data element in bits. | |
| pixelBitStride | back to summary |
|---|---|
| pack-priv int pixelBitStride The number of bits from one pixel to the next. | |
| pixelsPerDataElement | back to summary |
|---|---|
| pack-priv int pixelsPerDataElement The number of pixels that fit in a data element. Also used as the number of bits per pixel. | |
| scanlineStride | back to summary |
|---|---|
| pack-priv int scanlineStride ScanlineStride of the data buffer described in data array elements. | |
| MultiPixelPackedSampleModel | back to summary |
|---|---|
| public MultiPixelPackedSampleModel(int dataType, int w, int h, int numberOfBits) Constructs a
| |
| MultiPixelPackedSampleModel | back to summary |
|---|---|
| public MultiPixelPackedSampleModel(int dataType, int w, int h, int numberOfBits, int scanlineStride, int dataBitOffset) Constructs a
| |
| createCompatibleSampleModel | back to summary |
|---|---|
| public SampleModel createCompatibleSampleModel(int w, int h) Implements abstract java. Creates a new
| |
| createDataBuffer | back to summary |
|---|---|
| public DataBuffer createDataBuffer() Implements abstract java. Creates a
| |
| createSubsetSampleModel | back to summary |
|---|---|
| public SampleModel createSubsetSampleModel(int[] bands) Implements abstract java. Creates a new
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getBitOffset | back to summary |
|---|---|
| public int getBitOffset(int x) Returns the offset, in bits, into the data element in which it is
stored for the
| |
| getDataBitOffset | back to summary |
|---|---|
| public int getDataBitOffset() Returns the data bit offset in bits.
| |
| getDataElements | back to summary |
|---|---|
| public Object getDataElements(int x, int y, Object obj, DataBuffer data) Implements abstract java. Returns data for a single pixel in a primitive array of type
TransferType. For a
The following code illustrates transferring data for one pixel from
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
| |
| getNumDataElements | back to summary |
|---|---|
| public int getNumDataElements() Implements abstract java. Returns the number of data elements needed to transfer one pixel
via the
| |
| getOffset | back to summary |
|---|---|
| public int getOffset(int x, int y) Returns the offset of pixel (x, y) in data array elements.
| |
| getPixel | back to summary |
|---|---|
| public int[] getPixel(int x, int y, int[] iArray, DataBuffer data) Overrides java. Returns the specified single band pixel in the first element
of an
| |
| getPixelBitStride | back to summary |
|---|---|
| public int getPixelBitStride() Returns the pixel bit stride in bits. This value is the same as the number of bits per pixel.
| |
| getSample | back to summary |
|---|---|
| public int getSample(int x, int y, int b, DataBuffer data) Implements abstract java. Returns as
| |
| getSampleSize | back to summary |
|---|---|
| public int[] getSampleSize() Implements abstract java. Returns the number of bits per sample for all bands.
| |
| getSampleSize | back to summary |
|---|---|
| public int getSampleSize(int band) Implements abstract java. Returns the number of bits per sample for the specified band.
Since
| |
| getScanlineStride | back to summary |
|---|---|
| public int getScanlineStride() Returns the scanline stride.
| |
| getTransferType | back to summary |
|---|---|
| public int getTransferType() Overrides java. Returns the TransferType used to transfer pixels by way of the
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| setDataElements | back to summary |
|---|---|
| public void setDataElements(int x, int y, Object obj, DataBuffer data) Implements abstract java. Sets the data for a single pixel in the specified
The following code illustrates transferring data for one pixel from
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 SampleModel objects have
the same number of bands, corresponding bands have the same number of
bits per sample, and the TransferTypes are the same.
| |
| setPixel | back to summary |
|---|---|
| public void setPixel(int x, int y, int[] iArray, DataBuffer data) Overrides java. Sets a pixel in the
| |
| setSample | back to summary |
|---|---|
| public void setSample(int x, int y, int b, int s, DataBuffer data) Implements abstract java. Sets a sample in the specified band for the pixel located at
(x, y) in the
| |