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.SinglePixelPackedSampleModel
public class SinglePixelPackedSampleModel
extends SampleModel
SampleModel
used when all samples are stored in a single
data element in the DataBuffer
, and each data element contains
samples for one pixel only.
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 |
|
void |
|
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 SinglePixelPackedSampleModel(int dataType, int w, int h, int scanlineStride, int[] bitMasks)
Creates a newSinglePixelPackedSampleModel
.
- Parameters:
dataType
- the data buffer type.w
- the width (in pixels).h
- the height (in pixels).scanlineStride
- the number of data elements between a pixel on one row and the corresponding pixel on the next row.bitMasks
- an array containing the bit mask used to extract the sample value for each band.
public SinglePixelPackedSampleModel(int dataType, int w, int h, int[] bitMasks)
Creates a newSinglePixelPackedSampleModel
.
- Parameters:
dataType
- the data buffer type.w
- the width (in pixels).h
- the height (in pixels).bitMasks
- an array containing the bit mask used to extract the sample value for each band.
public SampleModel createCompatibleSampleModel(int w, int h)
Creates a newSampleModel
that is compatible with this model and has the specified width and height.
- 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:
- The data buffer.
public SampleModel createSubsetSampleModel(int[] bands)
Creates a newSinglePixelPackedSampleModel
that accesses the specified subset of bands.
- Overrides:
- createSubsetSampleModel in interface SampleModel
- Parameters:
bands
- an array containing band indices (null
not permitted).
- Returns:
- A new sample model.
- Throws:
NullPointerException
- ifbands
isnull
.RasterFormatException
- ifbands.length
is greater than the number of bands in this model.
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 ofSinglePixelPackedSampleModel
;- both models have the same:
dataType
;width
;height
;numBands
;scanlineStride
;bitMasks
;bitOffsets
.
- Parameters:
obj
- the object (null
permitted)
- Returns:
true
if this model is equal toobj
, andfalse
otherwise.
public Object getDataElements(int x, int y, Object obj, DataBuffer data)
- Overrides:
- getDataElements in interface SampleModel
public int getNumDataElements()
Returns the number of data elements.
- 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).
public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
Returns an array containing the samples for the pixel at (x, y) in the specified data buffer. IfiArray
is notnull
, it will be populated with the sample values 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:
- The pixel sample values.
- Throws:
NullPointerException
- ifdata
isnull
.
public int[] getPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
Returns an array containing the samples for the pixels in the region specified by (x, y, w, h) in the specified data buffer. The array is ordered by pixels (that is, all the samples for the first pixel are grouped together, followed by all the samples for the second pixel, and so on). IfiArray
is notnull
, it will be populated with the sample values and returned as the result of this function (this avoids allocating a new array instance).
- Overrides:
- getPixels in interface SampleModel
- Parameters:
x
- the x-coordinate of the top-left pixel.y
- the y-coordinate of the top-left pixel.w
- the width of the region of pixels.h
- the height of the region of pixels.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:
- The pixel sample values.
- Throws:
NullPointerException
- ifdata
isnull
.
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) for each band accessed by theSampleModel
.
- Overrides:
- getSampleSize in interface SampleModel
- Returns:
- An array.
- See Also:
getSampleSize(int)
public int getSampleSize(int band)
Returns the size (in bits) of the samples for the specified band.
- Overrides:
- getSampleSize in interface SampleModel
- Parameters:
band
- the band (in the range0
togetNumBands() - 1
).
- Returns:
- The sample size (in bits).
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 hashCode()
Returns a hash code for thisSinglePixelPackedSampleModel
.
- Returns:
- A hash code.
public void setDataElements(int x, int y, Object obj, DataBuffer data)
- Overrides:
- setDataElements in interface SampleModel
public void setPixel(int x, int y, int[] iArray, DataBuffer data)
Sets the samples for the pixel at (x, y) in the specified data buffer to the specified values.
- Overrides:
- setPixel in interface SampleModel
- Parameters:
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.iArray
- the sample values (null
not permitted).data
- the data buffer (null
not permitted).
- Throws:
NullPointerException
- if eitheriArray
ordata
isnull
.
public void setPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
This method implements a more efficient way to set pixels than the default implementation of the super class. It copies the pixel components directly from the input array instead of creating a intermediate buffer.
- Overrides:
- setPixels in interface SampleModel
- Parameters:
x
- The x-coordinate of the pixel rectangle inobj
.y
- The y-coordinate of the pixel rectangle inobj
.w
- The width of the pixel rectangle inobj
.h
- The height of the pixel rectangle inobj
.iArray
- The primitive array containing the pixels to set.data
- The DataBuffer to store the pixels into.
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
.