|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.image.SampleModel
java.awt.image.SinglePixelPackedSampleModel
public class SinglePixelPackedSampleModel
A 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 | |
---|---|
SinglePixelPackedSampleModel(int dataType,
int w,
int h,
int[] bitMasks)
Creates a new SinglePixelPackedSampleModel . |
|
SinglePixelPackedSampleModel(int dataType,
int w,
int h,
int scanlineStride,
int[] bitMasks)
Creates a new SinglePixelPackedSampleModel . |
Method Summary | |
---|---|
SampleModel |
createCompatibleSampleModel(int w,
int h)
Creates a new SampleModel that is compatible with this
model and has the specified width and height. |
DataBuffer |
createDataBuffer()
Creates a DataBuffer for holding pixel data in the format and layout described by this SampleModel. |
SampleModel |
createSubsetSampleModel(int[] bands)
Creates a new SinglePixelPackedSampleModel that accesses
the specified subset of bands. |
boolean |
equals(Object obj)
Tests this sample model for equality with an arbitrary object. |
int[] |
getBitMasks()
|
int[] |
getBitOffsets()
|
Object |
getDataElements(int x,
int y,
Object obj,
DataBuffer data)
This method is provided as a faster alternative to getPixel(), that can be used when there is no need to decode the pixel into separate sample values. |
int |
getNumDataElements()
Returns the number of data elements. |
int |
getOffset(int x,
int y)
Returns the index in the data buffer that stores the pixel at (x, y). |
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. |
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. |
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. |
int[] |
getSampleSize()
Returns an array containing the size (in bits) for each band accessed by the SampleModel . |
int |
getSampleSize(int band)
Returns the size (in bits) of the samples for the specified band. |
int |
getScanlineStride()
Returns the number of data elements from a pixel in one row to the corresponding pixel in the next row. |
int |
hashCode()
Returns a hash code for this SinglePixelPackedSampleModel . |
void |
setDataElements(int x,
int y,
Object obj,
DataBuffer data)
|
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. |
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. |
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. |
String |
toString()
Creates a String with some information about this SampleModel. |
Methods inherited from class java.awt.image.SampleModel |
---|
getDataElements, getDataType, getHeight, getNumBands, getPixel, getPixel, getPixels, getPixels, getSampleDouble, getSampleFloat, getSamples, getSamples, getSamples, getTransferType, getWidth, setDataElements, setPixel, setPixel, setPixels, setPixels, setSample, setSample, setSamples, setSamples, setSamples |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SinglePixelPackedSampleModel(int dataType, int w, int h, int[] bitMasks)
SinglePixelPackedSampleModel
.
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 SinglePixelPackedSampleModel(int dataType, int w, int h, int scanlineStride, int[] bitMasks)
SinglePixelPackedSampleModel
.
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.Method Detail |
---|
public int getNumDataElements()
getNumDataElements
in class SampleModel
1
.public SampleModel createCompatibleSampleModel(int w, int h)
SampleModel
that is compatible with this
model and has the specified width and height.
createCompatibleSampleModel
in class SampleModel
w
- the width (in pixels).h
- the height (in pixels).
public DataBuffer createDataBuffer()
createDataBuffer
in class SampleModel
public int[] getSampleSize()
SampleModel
.
getSampleSize
in class SampleModel
getSampleSize(int)
public int getSampleSize(int band)
getSampleSize
in class SampleModel
band
- the band (in the range 0
to
getNumBands() - 1
).
public int getOffset(int x, int y)
x
- the x-coordinate.y
- the y-coordinate.
public int[] getBitOffsets()
public int[] getBitMasks()
public int getScanlineStride()
public SampleModel createSubsetSampleModel(int[] bands)
SinglePixelPackedSampleModel
that accesses
the specified subset of bands.
createSubsetSampleModel
in class SampleModel
bands
- an array containing band indices (null
not
permitted).
NullPointerException
- if bands
is null
.
RasterFormatException
- if bands.length
is greater
than the number of bands in this model.public Object getDataElements(int x, int y, Object obj, DataBuffer data)
SampleModel
getDataElements
in class SampleModel
obj
- An array to return the pixel data in. If null, an
array of the right type and size will be created.
public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
iArray
is not null
,
it will be populated with the sample values and returned as the result of
this function (this avoids allocating a new array instance).
getPixel
in class SampleModel
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 (if null
, a new array will be allocated).data
- the data buffer (null
not permitted).
NullPointerException
- if data
is null
.public int[] getPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
iArray
is not null
, it will be
populated with the sample values and returned as the result of this
function (this avoids allocating a new array instance).
getPixels
in class SampleModel
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 (if null
, a new array will be allocated).data
- the data buffer (null
not permitted).
NullPointerException
- if data
is null
.public int getSample(int x, int y, int b, DataBuffer data)
getSample
in class SampleModel
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.b
- the band (in the range 0
to
getNumBands() - 1
).data
- the data buffer (null
not permitted).
NullPointerException
- if data
is null
.public void setDataElements(int x, int y, Object obj, DataBuffer data)
setDataElements
in class SampleModel
public void setPixel(int x, int y, int[] iArray, DataBuffer data)
setPixel
in class SampleModel
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).
NullPointerException
- if either iArray
or
data
is null
.public void setPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data)
setPixels
in class SampleModel
x
- The x-coordinate of the pixel rectangle in obj
.y
- The y-coordinate of the pixel rectangle in obj
.w
- The width of the pixel rectangle in obj
.h
- The height of the pixel rectangle in obj
.iArray
- The primitive array containing the pixels to set.data
- The DataBuffer to store the pixels into.SampleModel.setPixels(int, int, int, int, int[],
java.awt.image.DataBuffer)
public void setSample(int x, int y, int b, int s, DataBuffer data)
setSample
in class SampleModel
x
- the x-coordinate of the pixel.y
- the y-coordinate of the pixel.b
- the band (in the range 0
to
getNumBands() - 1
).s
- the sample value.data
- the data buffer (null
not permitted).
NullPointerException
- if data
is null
.public boolean equals(Object obj)
true
if and only if:
obj
is not null
;
obj
is an instance of
SinglePixelPackedSampleModel
;
dataType
;
width
;
height
;
numBands
;
scanlineStride
;
bitMasks
;
bitOffsets
.
equals
in class Object
obj
- the object (null
permitted)
true
if this model is equal to obj
, and
false
otherwise.Object.hashCode()
public int hashCode()
SinglePixelPackedSampleModel
.
hashCode
in class Object
Object.equals(Object)
,
System.identityHashCode(Object)
public String toString()
toString
in class Object
Object.toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |