Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Class java.awt.image.SinglePixelPackedSampleModel

java.lang.Object
    |
    +----java.awt.image.SampleModel
            |
            +----java.awt.image.SinglePixelPackedSampleModel

public class SinglePixelPackedSampleModel
extends SampleModel
This class extends SampleModel. It stores (packs) the N samples which make up a single pixel in 1 data array element. 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. Scanlinestride is the number of data array elements between a given sample and the 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.


Fields inherited from class java.awt.image.SampleModel
 dataType, height, numBands, width
 

Constructor Summary
 SinglePixelPackedSampleModel(int dataType, int w, int h, int[] bitMasks)
Constructs a SinglePixelPackedSampleModel with bitMasks.length bands.
 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
DataBuffer  createCompatibleDataBuffer()
Creates a DataBuffer that corresponds to this SinglePixelPackedSampleModel.
DataBuffer  createCompatibleDataBuffer(int desiredWidth, int desiredHeight)
Creates a DataBuffer that corresponds to this SinglePixelPackedSampleModel, with a different width and height.
SampleModel  createCompatibleSampleModel(int w, int h)
This creates a new SinglePixelPackedSampleModel with the specified width and height.
SampleModel  createSubsetSampleModel(int w, int h, int[] bands)
This creates a new SinglePixelPackedSampleModel with the specified width and height and with a subset of the bands of this SinglePixelPackedSampleModel.
int[]  getBitMasks()
Returns the bit masks for each band.
int[]  getBitOffsets()
Returns the bit offset into the data array element representing a pixel for each band.
int[]  getBitSizes()
Returns the size in bits of each band.
int  getNumDataElements()
Returns the number of data elements that are required to store one pixel.
long  getOffset(int x, int y)
Returns the offset (in data array elements) of pixel (x,y).
int[]  getPixel(int x, int y, int[] iArray, DataBuffer data)
Returns all samples in for the specified pixel in an int array.
int[]  getPixel(int x, int y, int w, int h, int[] iArray, DataBuffer data)
Returns all samples for the specified rectangle of pixels in an int array, one sample per array element.
int  getPixelBitSize()
Returns the size of a pixel in bits.
Object  getPixelData(int x, int y, Object obj, DataBuffer data)
Returns the pixel data in an array of primitives that can be byte, short or int.
int  getSample(int x, int y, int b, DataBuffer data)
Returns as int the sample in a specified band for the pixel located at (x,y).
int[]  getSample(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
Returns the samples in a specified band for the specified rectangle of pixels in an int array, one sample per data array element.
int[]  getSampleSize()
Returns the size in bits of samples for all bands.
int  getSampleSize(int band)
Returns the size in bits of samples for the specified band.
int  getScanlineStride()
Returns the scanline stride of this SinglePixelPackedSampleModel.
int  getTransferType()
Returns the transfer type of the data
void  setPixel(int x, int y, int[] iArray, DataBuffer data)
Sets a pixel in the DataBuffer using an int array of samples for input.
void  setPixel(int x, int y, int w, int h, int[] iArray, DataBuffer data)
Sets all samples for a rectangle of pixels from an int array containing one sample per data array element.
void  setPixelData(int x, int y, Object obj, DataBuffer data)
Puts the pixel data from an Object that contains an array of primitives that can be byte, short or int.
void  setSample(int x, int y, int b, int s, DataBuffer data)
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using an int for input.
void  setSample(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
Sets the samples in the specified band for the specified rectangle of pixels from an int array containing one sample per data array element.
 
Methods inherited from class java.awt.image.SampleModel
 createCompatibleDataBuffer, createCompatibleDataBuffer, createCompatibleSampleModel, createSubsetSampleModel, getDataType, getHeight, getMaxSampleValue, getMaxSampleValue, getMinSampleValue, getMinSampleValue, getNumBands, getNumDataElements, getPixel, getPixel, getPixel, getPixel, getPixel, getPixel, getPixelData, getPixelData, getSample, getSample, getSample, getSample, getSampleDouble, getSampleFloat, getSampleSize, getSampleSize, getTransferType, getWidth, setPixel, setPixel, setPixel, setPixel, setPixel, setPixel, setPixelData, setSample, setSample, setSample, setSample, setSample, setSample
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SinglePixelPackedSampleModel

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. Bit masks should be contiguous and should not overlap.
Parameters:
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 various bands.

SinglePixelPackedSampleModel

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. Bit masks should be contiguous and should not overlap.
Parameters:
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 region of image data described.
bitMasks - The bit masks for various bands.
Method Detail

getNumDataElements

public int getNumDataElements()
Returns the number of data elements that are required to store one pixel. For a SinglePixelPackedSampleModel, this is always one.
Overrides:
getNumDataElements in class SampleModel

createCompatibleSampleModel

public SampleModel createCompatibleSampleModel(int w,
                                               int h)
This creates a new SinglePixelPackedSampleModel with the specified width and height.
Overrides:
createCompatibleSampleModel in class SampleModel

createCompatibleDataBuffer

public DataBuffer createCompatibleDataBuffer()
Creates a DataBuffer that corresponds to this SinglePixelPackedSampleModel. The DataBuffer's width and height will match this SinglePixelPackedSampleModel's.
Overrides:
createCompatibleDataBuffer in class SampleModel

createCompatibleDataBuffer

public DataBuffer createCompatibleDataBuffer(int desiredWidth,
                                             int desiredHeight)
Creates a DataBuffer that corresponds to this SinglePixelPackedSampleModel, with a different width and height.
Overrides:
createCompatibleDataBuffer in class SampleModel

getPixelBitSize

public int getPixelBitSize()
Returns the size of a pixel in bits.

getSampleSize

public int[] getSampleSize()
Returns the size in bits of samples for all bands.
Overrides:
getSampleSize in class SampleModel

getSampleSize

public int getSampleSize(int band)
Returns the size in bits of samples for the specified band.
Overrides:
getSampleSize in class SampleModel

getOffset

public long getOffset(int x,
                      int y)
Returns the offset (in data array elements) of pixel (x,y). A sample of the first band can be retrieved from a dataBuffer data with a SinglePixelPackedSampleModel sppsm as
        data.getElem(sppsm.getOffset(x, y));
 

getBitOffsets

public int[] getBitOffsets()
Returns the bit offset into the data array element representing a pixel for each band.

getBitSizes

public int[] getBitSizes()
Returns the size in bits of each band.

getBitMasks

public int[] getBitMasks()
Returns the bit masks for each band.

getScanlineStride

public int getScanlineStride()
Returns the scanline stride of this SinglePixelPackedSampleModel.

getTransferType

public int getTransferType()
Returns the transfer type of the data
Overrides:
getTransferType in class SampleModel

createSubsetSampleModel

public SampleModel createSubsetSampleModel(int w,
                                           int h,
                                           int[] bands)
This creates a new SinglePixelPackedSampleModel with the specified width and height and with a subset of the bands of this SinglePixelPackedSampleModel.
Overrides:
createSubsetSampleModel in class SampleModel

getPixelData

public Object getPixelData(int x,
                           int y,
                           Object obj,
                           DataBuffer data)
Returns the pixel data in an array of primitives that can be byte, short or int. Which primitive type is returned depends on the transfer type. Data is returned in the packed format, thus increasing efficiency for data transfers. 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.
 	     SinglePixelPackedSampleModel sppsm1, sppsm2;
	     DataBufferInt db1, db2;
 	     sppsm2.setPixelData(x, y, sppsm1.getPixelData(x, y, null, db1), db2);
 
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
obj - If non-null, returns the primitive array in this object.
data - The DataBuffer containing the image data.
Overrides:
getPixelData in class SampleModel

getPixel

public int[] getPixel(int x,
                      int y,
                      int[] iArray,
                      DataBuffer data)
Returns all samples in for the specified pixel in an int array.
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
iArray - If non-null, returns the samples in this array
data - The DataBuffer containing the image data.
Overrides:
getPixel in class SampleModel

getPixel

public int[] getPixel(int x,
                      int y,
                      int w,
                      int h,
                      int[] iArray,
                      DataBuffer data)
Returns all samples for the specified rectangle of pixels in an int array, one sample per array element.
Parameters:
x - The X coordinate of the upper left pixel location.
y - The Y coordinate of the upper left pixel location.
w - The width of the pixel rectangle.
h - The height of the pixel rectangle.
iArray - If non-null, returns the samples in this array.
data - The DataBuffer containing the image data.
Overrides:
getPixel in class SampleModel

getSample

public int getSample(int x,
                     int y,
                     int b,
                     DataBuffer data)
Returns as int the sample in a specified band for the pixel located at (x,y).
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
b - The band to return.
data - The DataBuffer containing the image data.
Overrides:
getSample in class SampleModel

getSample

public int[] getSample(int x,
                       int y,
                       int w,
                       int h,
                       int b,
                       int[] iArray,
                       DataBuffer data)
Returns the samples in a specified band for the specified rectangle of pixels in an int array, one sample per data array element.
Parameters:
x - The X coordinate of the upper left pixel location.
y - The Y coordinate of the upper left pixel location.
w - The width of the pixel rectangle.
h - The height of the pixel rectangle.
b - The band to return.
iArray - If non-null, returns the samples in this array.
data - The DataBuffer containing the image data.
Overrides:
getSample in class SampleModel

setPixelData

public void setPixelData(int x,
                         int y,
                         Object obj,
                         DataBuffer data)
Puts the pixel data from an Object that contains an array of primitives that can be byte, short or int. Which primitive type it contains depends on the transfer type. Data in the Object is in the packed format, thus increasing efficiency for data transfers.
 	     SinglePixelPackedSampleModel sppsm1, sppsm2;
	     DataBufferInt db1, db2;
 	     sppsm2.setPixelData(x, y, sppsm1.getPixelData(x, y, null, db1), db2);
 
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
obj - If non-null, returns the primitive array in this object.
data - The DataBuffer containing the image data.
Overrides:
setPixelData in class SampleModel

setPixel

public void setPixel(int x,
                     int y,
                     int[] iArray,
                     DataBuffer data)
Sets a pixel in the DataBuffer using an int array of samples for input.
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
iArray - The input samples in an int array.
data - The DataBuffer containing the image data.
Overrides:
setPixel in class SampleModel

setPixel

public void setPixel(int x,
                     int y,
                     int w,
                     int h,
                     int[] iArray,
                     DataBuffer data)
Sets all samples for a rectangle of pixels from an int array containing one sample per data array element.
Parameters:
x - The X coordinate of the upper left pixel location.
y - The Y coordinate of the upper left pixel location.
w - The width of the pixel rectangle.
h - The height of the pixel rectangle.
iArray - The input samples in an int array.
data - The DataBuffer containing the image data.
Overrides:
setPixel in class SampleModel

setSample

public void setSample(int x,
                      int y,
                      int b,
                      int s,
                      DataBuffer data)
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using an int for input.
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
b - The band to set.
s - The input sample as an int.
data - The DataBuffer containing the image data.
Overrides:
setSample in class SampleModel

setSample

public void setSample(int x,
                      int y,
                      int w,
                      int h,
                      int b,
                      int[] iArray,
                      DataBuffer data)
Sets the samples in the specified band for the specified rectangle of pixels from an int array containing one sample per data array element.
Parameters:
x - The X coordinate of the upper left pixel location.
y - The Y coordinate of the upper left pixel location.
w - The width of the pixel rectangle.
h - The height of the pixel rectangle.
b - The band to set.
iArray - The input samples in an int array.
data - The DataBuffer containing the image data.
Overrides:
setSample in class SampleModel

Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.