Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.awt.image.SampleModel
java.awt.image.MultiPixelPackedSampleModel
public class MultiPixelPackedSampleModel
extends SampleModel
Field Summary |
Fields inherited from class java.awt.image.SampleModel | |
dataType , height , numBands , width |
Constructor Summary | |
| |
|
Method Summary | |
SampleModel |
|
DataBuffer |
|
SampleModel |
|
boolean | |
int |
|
int |
|
Object |
|
int |
|
int |
|
int[] |
|
int |
|
int |
|
int[] |
|
int |
|
int |
|
int |
|
int |
|
void |
|
void |
|
void |
|
String |
|
Methods inherited from class java.awt.image.SampleModel | |
createCompatibleSampleModel , createDataBuffer , createSubsetSampleModel , getDataElements , getDataElements , getDataType , getHeight , getNumBands , getNumDataElements , getPixel , getPixel , getPixel , getPixels , getPixels , getPixels , getSample , getSampleDouble , getSampleFloat , getSampleSize , getSampleSize , getSamples , getSamples , getSamples , getTransferType , getWidth , setDataElements , setDataElements , setPixel , setPixel , setPixel , setPixels , setPixels , setPixels , setSample , setSample , setSample , setSamples , setSamples , setSamples |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public MultiPixelPackedSampleModel(int dataType, int w, int h, int numberOfBits)
Creates a newMultiPixelPackedSampleModel
with the specified data type, which should be one of:
- Parameters:
dataType
- the data type.w
- the width (in pixels).h
- the height (in pixels).numberOfBits
- the number of bits per pixel (must be a power of 2).
public MultiPixelPackedSampleModel(int dataType, int w, int h, int numberOfBits, int scanlineStride, int dataBitOffset)
Creates a newMultiPixelPackedSampleModel
with the specified data type, which should be one of:
- Parameters:
dataType
- the data type.w
- the width (in pixels).h
- the height (in pixels).numberOfBits
- the number of bits per pixel (must be a power of 2).scanlineStride
- the number of data elements from a pixel on one row to the corresponding pixel in the next row.dataBitOffset
- the offset to the first data bit.
public SampleModel createCompatibleSampleModel(int w, int h)
Creates a newMultiPixelPackedSample
model with the same data type and bits per pixel as this model, but with the specified dimensions.
- Overrides:
- createCompatibleSampleModel in interface SampleModel
- Parameters:
w
- the width (in pixels).h
- the height (in pixels).
- Returns:
- The new sample model.
public DataBuffer createDataBuffer()
Creates a DataBuffer for holding pixel data in the format and layout described by this SampleModel. The returned buffer will consist of one single bank.
- Overrides:
- createDataBuffer in interface SampleModel
- Returns:
- A new data buffer.
public SampleModel createSubsetSampleModel(int[] bands)
Normally this method returns a sample model for accessing a subset of bands of image data, but sinceMultiPixelPackedSampleModel
only supports a single band, this overridden implementation just returns a new instance ofMultiPixelPackedSampleModel
, with the same attributes as this instance.
- Overrides:
- createSubsetSampleModel in interface SampleModel
- Parameters:
bands
- the bands to include in the subset (this is ignored, except that if it is non-null
a check is made to ensure that the array length is equal to1
).
- Throws:
RasterFormatException
- ifbands
is notnull
andbands.length != 1
.
public boolean equals(Object obj)
Tests this sample model for equality with an arbitrary object. This method returnstrue
if and only if:
obj
is notnull
;obj
is an instance ofMultiPixelPackedSampleModel
;- both models have the same:
dataType
;width
;height
;numberOfBits
;scanlineStride
;dataBitOffsets
.
- Parameters:
obj
- the object (null
permitted)
- Returns:
true
if this model is equal toobj
, andfalse
otherwise.
public int getBitOffset(int x)
The bit offset (within an element in the data buffer) of the pixels with the specified x-coordinate.
- Parameters:
x
- the x-coordinate.
- Returns:
- The bit offset.
public int getDataBitOffset()
Returns the offset to the first data bit.
- Returns:
- The offset to the first data bit.
public Object getDataElements(int x, int y, Object obj, DataBuffer data)
Extract one pixel and return in an array of transfer type. Extracts the pixel at x, y from data and stores into the 0th index of the array obj, since there is only one band. If obj is null, a new array of getTransferType() is created.
- Overrides:
- getDataElements in interface SampleModel
- Parameters:
x
- The x-coordinate of the pixel rectangle to store inobj
.y
- The y-coordinate of the pixel rectangle to store inobj
.obj
- The primitive array to store the pixels into or null to force creation.data
- The DataBuffer that is the source of the pixel data.
- Returns:
- The primitive array containing the pixel data.
public int getNumDataElements()
Returns the number of data elements required to transfer a pixel in the get/setDataElements() methods.
- Overrides:
- getNumDataElements in interface SampleModel
- Returns:
1
.
public int getOffset(int x, int y)
Returns the index in the data buffer that stores the pixel at (x, y).
- Parameters:
x
- the x-coordinate.y
- the y-coordinate.
- Returns:
- The index in the data buffer that stores the pixel at (x, y).
- See Also:
getBitOffset(int)
public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
Returns an array (of length 1) containing the sample for the pixel at (x, y) in the specified data buffer. IfiArray
is notnull
, it will be populated with the sample value and returned as the result of this function (this avoids allocating a new array instance).
- Overrides:
- getPixel in interface SampleModel
- Parameters:
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.iArray
- an array to populate with the sample values and return as the result (ifnull
, a new array will be allocated).data
- the data buffer (null
not permitted).
- Returns:
- An array containing the pixel sample value.
- Throws:
NullPointerException
- ifdata
isnull
.
public int getPixelBitStride()
Returns the number of bits per pixel.
- Returns:
- The number of bits per pixel.
public int getSample(int x, int y, int b, DataBuffer data)
Returns the sample value for the pixel at (x, y) in the specified data buffer.
- Overrides:
- getSample in interface SampleModel
- Parameters:
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.b
- the band (in the range0
togetNumBands() - 1
).data
- the data buffer (null
not permitted).
- Returns:
- The sample value.
- Throws:
NullPointerException
- ifdata
isnull
.
public int[] getSampleSize()
Returns an array containing the size (in bits) of the samples in each band. TheMultiPixelPackedSampleModel
class supports only one band, so this method returns an array with length1
.
- Overrides:
- getSampleSize in interface SampleModel
- Returns:
- An array containing the size (in bits) of the samples in band zero.
- See Also:
getSampleSize(int)
public int getSampleSize(int band)
Returns the size of the samples in the specified band. Note that theMultiPixelPackedSampleModel
supports only one band -- this method ignored theband
argument, and always returns the size of band zero.
- Overrides:
- getSampleSize in interface SampleModel
- Parameters:
band
- the band (this parameter is ignored).
- Returns:
- The size of the samples in band zero.
- See Also:
getSampleSize()
public int getScanlineStride()
Returns the number of data elements from a pixel in one row to the corresponding pixel in the next row.
- Returns:
- The scanline stride.
public int getTransferType()
Returns the transfer type, which is one of the following (depending on the number of bits per sample for this model):
- Overrides:
- getTransferType in interface SampleModel
- Returns:
- The transfer type.
public int hashCode()
Returns a hash code for thisMultiPixelPackedSampleModel
.
- Returns:
- A hash code.
public void setDataElements(int x, int y, Object obj, DataBuffer data)
Set the pixel at x, y to the value in the first element of the primitive array obj.
- Overrides:
- setDataElements in interface SampleModel
- Parameters:
x
- The x-coordinate of the data elements inobj
.y
- The y-coordinate of the data elements inobj
.obj
- The primitive array containing the data elements to set.data
- The DataBuffer to store the data elements into.
public void setPixel(int x, int y, int[] iArray, DataBuffer data)
Sets the sample value for the pixel at (x, y) in the specified data buffer to the specified value.
- Overrides:
- setPixel in interface SampleModel
- Parameters:
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.iArray
- the sample value (null
not permitted).data
- the data buffer (null
not permitted).
- Throws:
NullPointerException
- if eitheriArray
ordata
isnull
.
public void setSample(int x, int y, int b, int s, DataBuffer data)
Sets the sample value for a band for the pixel at (x, y) in the specified data buffer.
- Overrides:
- setSample in interface SampleModel
- Parameters:
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.b
- the band (in the range0
togetNumBands() - 1
).s
- the sample value.data
- the data buffer (null
not permitted).
- Throws:
NullPointerException
- ifdata
isnull
.