|
JSR-209 (Final Release) | ||||||||||
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
This class represents pixel data packed such that the N samples which make
up a single pixel are stored in a single data array element, and each data
data array element holds samples for only one pixel.
This class supports
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];
Field Summary |
Fields inherited from class java.awt.image.SampleModel |
dataType, height, numBands, width |
Constructor Summary | |
protected |
SinglePixelPackedSampleModel(int dataType,
int w,
int h,
int[] bitMasks)
Constructs a SinglePixelPackedSampleModel with bitMasks.length bands. |
protected |
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. |
Method Summary | |
boolean |
equals(java.lang.Object o)
Sets the samples in the specified band for the specified rectangle of pixels from an int array containing one sample per array element. |
int[] |
getBitMasks()
Returns the bit masks for all bands. |
int[] |
getBitOffsets()
Returns the bit offsets into the data array element representing a pixel for all bands. |
int |
getOffset(int x,
int y)
Returns the offset (in data array elements) of pixel (x,y). |
int[] |
getSampleSize()
Returns the number of bits per sample for all bands. |
int |
getScanlineStride()
Returns the scanline stride of this SinglePixelPackedSampleModel. |
int |
hashCode()
|
Methods inherited from class java.awt.image.SampleModel |
getDataType, getHeight, getNumBands, getWidth |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected SinglePixelPackedSampleModel(int dataType, int w, int h, int[] bitMasks)
dataType
- The data type for storing samples.w
- The width (in pixels) of the region of the
image data described.h
- The height (in pixels) of the region of the
image data described.bitMasks
- The bit masks for all bands.
java.lang.IllegalArgumentException
- if dataType
is not
either DataBuffer.TYPE_BYTE
,
DataBuffer.TYPE_USHORT
, or
DataBuffer.TYPE_INT
protected SinglePixelPackedSampleModel(int dataType, int w, int h, int scanlineStride, int[] bitMasks)
dataType
- The data type for storing samples.w
- The width (in pixels) of the region of
image data described.h
- The height (in pixels) of the region of
image data described.scanlineStride
- The line stride of the image data.bitMasks
- The bit masks for all bands.
java.lang.IllegalArgumentException
- if w
or
h
is not greater than 0
java.lang.IllegalArgumentException
- if any mask in
bitMask
is not contiguous
java.lang.IllegalArgumentException
- if dataType
is not
either DataBuffer.TYPE_BYTE
,
DataBuffer.TYPE_USHORT
, or
DataBuffer.TYPE_INT
Method Detail |
public int[] getSampleSize()
getSampleSize
in class SampleModel
public int getOffset(int x, int y)
x,y
can be retrieved from a DataBuffer data
with a
SinglePixelPackedSampleModel sppsm
as:
data.getElem(sppsm.getOffset(x, y));
public int[] getBitOffsets()
public int[] getBitMasks()
public int getScanlineStride()
SinglePixelPackedSampleModel
.public boolean equals(java.lang.Object o)
#getSamples(int, int, int, int, int, int[], DataBuffer)
public int hashCode()
|
JSR-209 (Final Release) | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |