TYPE_BYTE,
TYPE_USHORT,
TYPE_INT data types.
All data array elements reside
in the first bank of a DataBuffer. Accessor methods are provided so
that the image data can be manipulated directly. Scanline stride is the
number of data array elements between a given sample and the corresponding
sample in the same column of the next scanline. Bit masks are the masks
required to extract the samples representing the bands of the pixel.
Bit offsets are the offsets in bits into the data array
element of the samples representing the bands of the pixel.
The following code illustrates extracting the bits of the sample
representing band b for pixel x,y
from DataBuffer data:
int sample = data.getElem(y * scanlineStride + x);
sample = (sample & bitMasks[b]) >>> bitOffsets[b];
| Modifier and Type | Field and Description |
|---|---|
| private int[] | bitMasks
Bit masks for all bands of the image data. |
| private int[] | bitOffsets
Bit Offsets for all bands of the image data. |
| private int[] | bitSizes
Bit sizes for all the bands of the image data. |
| private int | maxBitSize
Maximum bit size. |
| private int | scanlineStride
Line stride of the region of image data described by this SinglePixelPackedSampleModel. |
| Access | Constructor and Description |
|---|---|
| public | SinglePixelPackedSampleModel(int
The data type for storing samples. dataType, int The width (in pixels) of the region of the
image data described. w, int The height (in pixels) of the region of the
image data described. h, int[] The bit masks for all bands. bitMasks)Constructs a SinglePixelPackedSampleModel with bitMasks.length bands. |
| public | SinglePixelPackedSampleModel(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 line stride of the image data. scanlineStride, int[] The bit masks for all bands. bitMasks)Constructs a SinglePixelPackedSampleModel with bitMasks.length bands and a scanline stride equal to scanlineStride data array elements. |
| Modifier and Type | Method and Description |
|---|---|
| public SampleModel | Returns: aSinglePixelPackedSampleModel with the
specified width and height.the width of the resulting w, int SampleModelthe height of the resulting h)SampleModelImplements abstract java. Creates a new SinglePixelPackedSampleModel with the specified width and height. |
| public DataBuffer | createDataBuffer()
Implements abstract java. Creates a DataBuffer that corresponds to this SinglePixelPackedSampleModel. |
| public SampleModel | createSubsetSampleModel(int[] bands)
Implements abstract java. This creates a new SinglePixelPackedSampleModel with a subset of the bands of this SinglePixelPackedSampleModel. |
| public boolean | equals(Object o)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public int[] | |
| public int[] | Returns: the bit offsets representing a pixel for all bands.Returns the bit offsets into the data array element representing a pixel for all bands. |
| private long | getBufferSize()
Returns the size of the buffer (in data array elements) needed for a data buffer that matches this SinglePixelPackedSampleModel. |
| public Object | Returns: the data for the specified pixel.The X coordinate of the pixel location. x, int The Y coordinate of the pixel location. y, Object If non-null, a primitive array in which to return
the pixel data. obj, DataBuffer The DataBuffer containing the image data. data)Implements abstract java. Returns data for a single pixel in a primitive array of type TransferType. |
| public int | getNumDataElements()
Implements abstract java. Returns the number of data elements needed to transfer one pixel via the getDataElements and setDataElements methods. |
| 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 (in data array elements) of pixel (x,y). |
| public int[] | getPixel(int x, int y, int[] iArray, DataBuffer data)
Overrides java. Returns the samples for a specified pixel in an int array, one sample per array element. |
| public int[] | getPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
Overrides java. Returns all samples for a rectangle of pixels in an int array, one sample per array element. |
| public int | getSample(int x, int y, int b, DataBuffer data)
Implements abstract java. Returns the sample in a specified band for the pixel located at (x,y) as an int. |
| public int[] | getSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
Overrides java. Returns the samples for a specified band for the specified rectangle of pixels in an int array, one sample per array element. |
| public int[] | getSampleSize()
Implements abstract java. Returns the number of bits per sample for all bands. |
| public int | Returns: the size of the samples of the specified band.the specified band band)Implements abstract java. Returns the number of bits per sample for the specified band. |
| public int | Returns: the scanline stride of thisSinglePixelPackedSampleModel.Returns the scanline stride of this SinglePixelPackedSampleModel. |
| public int | |
| private static native void | |
| 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 DataBuffer containing the image data. data)Implements abstract java. Sets the data for a single pixel in the specified DataBuffer from a primitive array of type TransferType. |
| public void | setPixel(int x, int y, int[] iArray, DataBuffer data)
Overrides java. Sets a pixel in the DataBuffer using an int array of samples for input. |
| public void | setPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
Overrides java. Sets all samples for a rectangle of pixels from an int array containing one sample per array element. |
| 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 DataBuffer using an int for input. |
| public void | setSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
Overrides java. Sets the samples in the specified band for the specified rectangle of pixels from an int array containing one sample per array element. |
| bitMasks | back to summary |
|---|---|
| private int[] bitMasks Bit masks for all bands of the image data. | |
| bitOffsets | back to summary |
|---|---|
| private int[] bitOffsets Bit Offsets for all bands of the image data. | |
| bitSizes | back to summary |
|---|---|
| private int[] bitSizes Bit sizes for all the bands of the image data. | |
| maxBitSize | back to summary |
|---|---|
| private int maxBitSize Maximum bit size. | |
| scanlineStride | back to summary |
|---|---|
| private int scanlineStride Line stride of the region of image data described by this SinglePixelPackedSampleModel. | |
| SinglePixelPackedSampleModel | back to summary |
|---|---|
| public SinglePixelPackedSampleModel(int dataType, int w, int h, int[] bitMasks) Constructs a SinglePixelPackedSampleModel with bitMasks.length bands. Each sample is stored in a data array element in the position of its corresponding bit mask. Each bit mask must be contiguous and masks must not overlap. Bit masks exceeding data type capacity are truncated.
| |
| SinglePixelPackedSampleModel | back to summary |
|---|---|
| public SinglePixelPackedSampleModel(int dataType, int w, int h, int scanlineStride, int[] bitMasks) Constructs a SinglePixelPackedSampleModel with bitMasks.length bands and a scanline stride equal to scanlineStride data array elements. Each sample is stored in a data array element in the position of its corresponding bit mask. Each bit mask must be contiguous and masks must not overlap. Bit masks exceeding data type capacity are truncated.
| |
| createCompatibleSampleModel | back to summary |
|---|---|
| public SampleModel createCompatibleSampleModel(int w, int h) Implements abstract java. Creates a new SinglePixelPackedSampleModel with the specified width and height. The new SinglePixelPackedSampleModel will have the same storage data type and bit masks as this SinglePixelPackedSampleModel.
| |
| createDataBuffer | back to summary |
|---|---|
| public DataBuffer createDataBuffer() Implements abstract java. Creates a DataBuffer that corresponds to this SinglePixelPackedSampleModel. The DataBuffer's data type and size will be consistent with this SinglePixelPackedSampleModel. The DataBuffer will have a single bank. | |
| createSubsetSampleModel | back to summary |
|---|---|
| public SampleModel createSubsetSampleModel(int[] bands) Implements abstract java. This creates a new SinglePixelPackedSampleModel with a subset of the bands of this SinglePixelPackedSampleModel. The new SinglePixelPackedSampleModel can be used with any DataBuffer that the existing SinglePixelPackedSampleModel can be used with. The new SinglePixelPackedSampleModel/DataBuffer combination will represent an image with a subset of the bands of the original SinglePixelPackedSampleModel/DataBuffer combination.
| |
| 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. | |
| getBitMasks | back to summary |
|---|---|
| public int[] getBitMasks() Returns the bit masks for all bands.
| |
| getBitOffsets | back to summary |
|---|---|
| public int[] getBitOffsets() Returns the bit offsets into the data array element representing a pixel for all bands.
| |
| getBufferSize | back to summary |
|---|---|
| private long getBufferSize() Returns the size of the buffer (in data array elements) needed for a data buffer that matches this SinglePixelPackedSampleModel. | |
| 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 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
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.
| |
| getNumDataElements | back to summary |
|---|---|
| public int getNumDataElements() Implements abstract java. Returns the number of data elements needed to transfer one pixel via the getDataElements and setDataElements methods. For a SinglePixelPackedSampleModel, this is one. | |
| getOffset | back to summary |
|---|---|
| public int getOffset(int x, int y) Returns the offset (in data array elements) of pixel (x,y).
The data element containing pixel
data.getElem(sppsm.getOffset(x, y));
| |
| getPixel | back to summary |
|---|---|
| public int[] getPixel(int x, int y, int[] iArray, DataBuffer data) Overrides java. Doc from java. 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.
| |
| getPixels | back to summary |
|---|---|
| public int[] getPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data) Overrides java. Doc from java. 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.
| |
| getSample | back to summary |
|---|---|
| public int getSample(int x, int y, int b, DataBuffer data) Implements abstract java. Doc from java. 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.
| |
| getSamples | back to summary |
|---|---|
| public int[] getSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data) Overrides java. Doc from java. 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.
| |
| 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.
| |
| getScanlineStride | back to summary |
|---|---|
| public int getScanlineStride() Returns the scanline stride of this SinglePixelPackedSampleModel.
| |
| 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
| |
| initIDs | back to summary |
|---|---|
| private static native void initIDs() | |
| 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 DataBuffer from a primitive array of type TransferType. For a SinglePixelPackedSampleModel, only the first element of the array will hold valid data, and the type of the array must be the same as the storage data type of the SinglePixelPackedSampleModel.
The following code illustrates transferring data for one pixel from
DataBuffer
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.
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.
| |
| setPixel | back to summary |
|---|---|
| public void setPixel(int x, int y, int[] iArray, DataBuffer data) Overrides java. Doc from java. 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.
| |
| setPixels | back to summary |
|---|---|
| public void setPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data) Overrides java. Doc from java. 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.
| |
| setSample | back to summary |
|---|---|
| public void setSample(int x, int y, int b, int s, DataBuffer data) Implements abstract java. Doc from java. 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. | |
| setSamples | back to summary |
|---|---|
| public void setSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data) Overrides java. Doc from java. 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.
| |