All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class java.awt.image.SingleBandPackedSampleModel

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

public class SingleBandPackedSampleModel
extends SampleModel
This class extends SampleModel. It only stores one-banded images, but it can pack multiple one-sample pixels into one data element. Note that pixels are not allowed to span data element. In addition, each pixel must be a power of 2 number of bits and a power of 2 number of pixels must fit exactly in one data element. Pixel bit stride is equal to the number of bits per pixel. Scanline stride is in data elements so the last data element may be padded with unused pixels. Data bit offset must be a multiple of pixel bit stride.


Constructor Index

 o SingleBandPackedSampleModel(int, int, int, int)
Constructs a SingleBandPackedSampleModel with the given data type, width, height and number of bits per pixel.
 o SingleBandPackedSampleModel(int, int, int, int, int, int)
Constructs a SingleBandPackedSampleModel with given data type, width, height, number of bits per pixel, scanline stride and data bit offset.

Method Index

 o createCompatibleDataBuffer()
Creates a DataBuffer of the correct type big enough to hold all pixels described by this SingleBandPackedSampleModel.
 o createCompatibleDataBuffer(int, int)
Creates a DataBuffer of the correct type big enough to hold all pixels described by this SingleBandPackedSampleModel with the desired height and width.
 o createCompatibleSampleModel(int, int)
Creates a new SinglePackedSampleModel with the requested width and height.
 o createSubsetSampleModel(int, int, int[])
This creates a new SampleModel with the requested physical width and height and with a subset of the components of this SampleModel.
 o getBitOffset(int)
Returns offset in bits of the xth pixel of a scanline into the data element in which it's stored.
 o getDataBitOffset()
Returns the data bit offset in bits.
 o getNumDataElements()
Returns the number of data elements required to store one pixel.
 o getOffset(int, int)
Returns the offset (in data array elements) of pixel (x,y).
 o getPixel(int, int, int[], DataBuffer)
Returns the requested pixel as an int.
 o getPixelBitSize()
Returns the size of a pixel in bits.
 o getPixelBitStride()
Returns the pixel bit stride in bits.
 o getPixelData(int, int, Object, DataBuffer)
Returns the pixel data in an array of primitives that can be byte, short or int.
 o getSample(int, int, int, DataBuffer)
Returns the sample in a specified band for a pixel as an int.
 o getSampleSize()
Returns the size of all bands in bits.
 o getSampleSize(int)
Returns the size of the requested bands in bits.
 o getScanlineStride()
Returns the scanline stride.
 o getTransferType()
Returns the tranfer type of the data
 o setPixel(int, int, int[], DataBuffer)
Sets a pixel in the DataBuffer using an int for input.
 o setPixelData(int, int, Object, DataBuffer)
Puts the pixel data from an Object that contains an array of primitives that can be byte, short or int.
 o setSample(int, int, int, int, DataBuffer)
Sets a sample in the DataBuffer using an int for input.

Constructors

 o SingleBandPackedSampleModel
public SingleBandPackedSampleModel(int dataType,
                                   int w,
                                   int h,
                                   int numberOfBits)
Constructs a SingleBandPackedSampleModel with the given data type, width, height and number of bits per pixel.

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.
numofBits - The pixelBitStride for the region of image data described.
 o SingleBandPackedSampleModel
public SingleBandPackedSampleModel(int dataType,
                                   int w,
                                   int h,
                                   int pixelBitStride,
                                   int scanlineStride,
                                   int dataBitOffset)
Constructs a SingleBandPackedSampleModel with given data type, width, height, number of bits per pixel, scanline stride and data bit offset.

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.
pixelBitStride - The pixelBitStride of the region of image data described.
scanlineStride - The line stride of the region of the image data described.
dataBitOffset - The data bit offset for the region of image data described.

Methods

 o createCompatibleSampleModel
public SampleModel createCompatibleSampleModel(int w,
                                               int h)
Creates a new SinglePackedSampleModel with the requested width and height.

Overrides:
createCompatibleSampleModel in class SampleModel
 o createCompatibleDataBuffer
public DataBuffer createCompatibleDataBuffer()
Creates a DataBuffer of the correct type big enough to hold all pixels described by this SingleBandPackedSampleModel.

Overrides:
createCompatibleDataBuffer in class SampleModel
 o createCompatibleDataBuffer
public DataBuffer createCompatibleDataBuffer(int desiredWidth,
                                             int desiredHeight)
Creates a DataBuffer of the correct type big enough to hold all pixels described by this SingleBandPackedSampleModel with the desired height and width.

Overrides:
createCompatibleDataBuffer in class SampleModel
 o getPixelBitSize
public int getPixelBitSize()
Returns the size of a pixel in bits. This is equal to the pixel bit stride.

 o getNumDataElements
public int getNumDataElements()
Returns the number of data elements required to store one pixel.

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

Overrides:
getSampleSize in class SampleModel
 o getSampleSize
public int getSampleSize(int band)
Returns the size of the requested bands in bits.

Overrides:
getSampleSize in class SampleModel
 o getOffset
public long getOffset(int x,
                      int y)
Returns the offset (in data array elements) of pixel (x,y).

 o getBitOffset
public int getBitOffset(int x)
Returns offset in bits of the xth pixel of a scanline into the data element in which it's stored.

 o getScanlineStride
public int getScanlineStride()
Returns the scanline stride.

 o getPixelBitStride
public int getPixelBitStride()
Returns the pixel bit stride in bits. Same as pixel bit size.

 o getDataBitOffset
public int getDataBitOffset()
Returns the data bit offset in bits.

 o getTransferType
public int getTransferType()
Returns the tranfer type of the data

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

Overrides:
createSubsetSampleModel in class SampleModel
 o getSample
public int getSample(int x,
                     int y,
                     int b,
                     DataBuffer data)
Returns the sample in a specified band for a pixel as an int.

Parameters:
x - The X coordinate of the pixel location
y - The Y coordinate of the pixel location
b - The band to return (assumed to be 0)
data - The DataBuffer where image data is stored.
Overrides:
getSample in class SampleModel
 o setSample
public void setSample(int x,
                      int y,
                      int b,
                      int s,
                      DataBuffer data)
Sets a sample 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 return (assumed to be 0)
s - The input sample as an int
data - The DataBuffer where image data is stored
Overrides:
setSample in class SampleModel
 o 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.
 	     SingleBandPackedSampleModel spsm1, spsm2;
	     DataBufferInt db1, db2;
 	     spsm2.setPixelData(x, y, spsm1.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
 o getPixel
public int[] getPixel(int x,
                      int y,
                      int[] iArray,
                      DataBuffer data)
Returns the requested pixel as an int.

Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
data - The DataBuffer where image data is stored.
Overrides:
getPixel in class SampleModel
 o 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.
 	     SingleBandPackedSampleModel spsm1, spsm2;
	     DataBufferInt db1, db2;
 	     spsm2.setPixelData(x, y, spsm1.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
 o setPixel
public void setPixel(int x,
                     int y,
                     int[] iArray,
                     DataBuffer data)
Sets a pixel 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
s - The input sample as an int
data - The DataBuffer where image data is stored
Overrides:
setPixel in class SampleModel

All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Submit a bug or feature