java.awt.image
Class SinglePixelPackedSampleModel

java.lang.Object
  |
  +--java.awt.image.SampleModel
        |
        +--java.awt.image.SinglePixelPackedSampleModel
public class SinglePixelPackedSampleModel
extends SampleModel

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

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

 SampleModel createCompatibleSampleModel(int w, int h)
    Creates a new SinglePixelPackedSampleModel with the specified width and height.
 DataBuffer createDataBuffer()
    Creates a DataBuffer that corresponds to this SinglePixelPackedSampleModel.
 SampleModel createSubsetSampleModel(int[] bands)
    This creates a new SinglePixelPackedSampleModel with a subset of the bands of this SinglePixelPackedSampleModel.
 boolean equals(Object o)
    Indicates whether some other object is "equal to" this one.
 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.
 Object getDataElements(int x, int y, Object obj, DataBuffer data)
    Returns data for a single pixel in a primitive array of type TransferType.
 int getNumDataElements()
    Returns the number of data elements needed to transfer one pixel via the getDataElements and setDataElements methods.
 int 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[] getPixels(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 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[] getSamples(int x, int y, int w, int h, int b, int[] iArray, DataBuffer data)
    Returns the samples for a specified band for the specified rectangle of pixels in an int array, one sample per array element.
 int[] getSampleSize()
    Returns the number of bits per sample for all bands.
 int getSampleSize(int band)
    Returns the number of bits per sample for the specified band.
 int getScanlineStride()
    Returns the scanline stride of this SinglePixelPackedSampleModel.
 int hashCode()
    Returns a hash code value for the object.
 void setDataElements(int x, int y, Object obj, DataBuffer data)
    Sets the data for a single pixel in the specified DataBuffer from a primitive array of type TransferType.
 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 setPixels(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 array element.
 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 setSamples(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 array element.
 
Methods inherited from class java.awt.image.SampleModel
getDataElements, getDataType,