|
|||||||||
| Home >> All >> non_com >> media >> [ jai overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
non_com.media.jai
Class ComponentSampleModelJAI

java.lang.Objectjava.awt.image.SampleModel
java.awt.image.ComponentSampleModel
non_com.media.jai.ComponentSampleModelJAI
- public class ComponentSampleModelJAI
- extends java.awt.image.ComponentSampleModel
This class represents image data which is stored such that each sample of a
pixel occupies one data element of the DataBuffer. It stores
the N samples which make up a pixel in N separate data array elements.
Different bands may be in different banks of the DataBuffer.
Accessor methods are provided so that image data can be manipulated
directly. This class can support different kinds of interleaving, e.g. band
interleaving, scanline interleaving, and pixel interleaving. Pixel stride is
the number of data array elements between two samples for the same band on
the same scanline. 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. Band offsets denote the number of data array elements
from the first data array element of the bank of the DataBuffer
holding each band to the first sample of the band. The bands are numbered
from 0 to N-1. This class can represent image data for the dataTypes
enumerated in java.awt.image.DataBuffer (all samples of a given ComponentSampleModel
are stored with the same precision) . This class adds support for Double
and Float data types in addition to those supported by the
ComponentSampleModel class in Java 2D. All strides and offsets
must be non-negative.
| Field Summary |
| Fields inherited from class java.awt.image.ComponentSampleModel |
bandOffsets, bankIndices, numBands, numBanks, pixelStride, scanlineStride |
| Fields inherited from class java.awt.image.SampleModel |
dataType, height, width |
| Constructor Summary | |
ComponentSampleModelJAI(int dataType,
int w,
int h,
int pixelStride,
int scanlineStride,
int[] bandOffsets)
Constructs a ComponentSampleModel with the specified
parameters. |
|
ComponentSampleModelJAI(int dataType,
int w,
int h,
int pixelStride,
int scanlineStride,
int[] bankIndices,
int[] bandOffsets)
Constructs a ComponentSampleModel with the specified
parameters. |
|
| Method Summary | |
java.awt.image.SampleModel |
createCompatibleSampleModel(int w,
int h)
Creates a new ComponentSampleModel with the specified width
and height. |
java.awt.image.DataBuffer |
createDataBuffer()
Creates a DataBuffer that corresponds to this ComponentSampleModel
. |
java.awt.image.SampleModel |
createSubsetSampleModel(int[] bands)
This creates a new ComponentSampleModel with a subset of the
bands of this ComponentSampleModel. |
private long |
getBufferSize()
Returns the size of the data buffer (in data elements) needed for a data buffer that matches this ComponentSampleModel. |
java.lang.Object |
getDataElements(int x,
int y,
int w,
int h,
java.lang.Object obj,
java.awt.image.DataBuffer data)
Returns the pixel data for the specified rectangle of pixels in a primitive array of type TransferType. |
java.lang.Object |
getDataElements(int x,
int y,
java.lang.Object obj,
java.awt.image.DataBuffer data)
Returns data for a single pixel in a primitive array of type TransferType. |
double[] |
getPixels(int x,
int y,
int w,
int h,
double[] dArray,
java.awt.image.DataBuffer data)
Returns all samples for a rectangle of pixels in a double
array, one sample per array element. |
double |
getSampleDouble(int x,
int y,
int b,
java.awt.image.DataBuffer data)
Returns the sample in a specified band for a pixel located at (x,y) as a double. |
float |
getSampleFloat(int x,
int y,
int b,
java.awt.image.DataBuffer data)
Returns the sample in a specified band for the pixel located at (x,y) as a float. |
private int[] |
JAIorderBands(int[] orig,
int step)
Preserves band ordering with new step factor... |
void |
setDataElements(int x,
int y,
int w,
int h,
java.lang.Object obj,
java.awt.image.DataBuffer data)
Sets the data for a rectangle of pixels in the specified DataBuffer
from a primitive array of type TransferType. |
void |
setDataElements(int x,
int y,
java.lang.Object obj,
java.awt.image.DataBuffer data)
Sets the data for a single pixel in the specified DataBuffer
from a primitive array of type TransferType. |
void |
setSample(int x,
int y,
int b,
double s,
java.awt.image.DataBuffer data)
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using a double for input. |
void |
setSample(int x,
int y,
int b,
float s,
java.awt.image.DataBuffer data)
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using a float for input. |
java.lang.String |
toString()
Returns a String containing the values of all valid fields. |
| Methods inherited from class java.awt.image.ComponentSampleModel |
equals, getBandOffsets, getBankIndices, getNumDataElements, getOffset, getOffset, getPixel, getPixels, getPixelStride, getSample, getSampleSize, getSampleSize, getScanlineStride, hashCode, setPixel, setSample |
| Methods inherited from class java.awt.image.SampleModel |
getDataType, getHeight, getNumBands, getPixel, getPixel, getPixels, getSamples, getSamples, getSamples, getTransferType, getWidth, setPixel, setPixel, setPixels, setPixels, setPixels, setSamples, setSamples, setSamples |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
ComponentSampleModelJAI
public ComponentSampleModelJAI(int dataType,
int w,
int h,
int pixelStride,
int scanlineStride,
int[] bandOffsets)
- Constructs a
ComponentSampleModelwith the specified parameters. The number of bands will be given by the length of the bandOffsets array. All bands will be stored in the first bank of theDataBuffer.
ComponentSampleModelJAI
public ComponentSampleModelJAI(int dataType,
int w,
int h,
int pixelStride,
int scanlineStride,
int[] bankIndices,
int[] bandOffsets)
- Constructs a
ComponentSampleModelwith the specified parameters. The number of bands will be given by the length of the bandOffsets array. Different bands may be stored in different banks of theDataBuffer.
| Method Detail |
setDataElements
public void setDataElements(int x,
int y,
java.lang.Object obj,
java.awt.image.DataBuffer data)
- Sets the data for a single pixel in the specified
DataBufferfrom a primitive array of type TransferType. For aComponentSampleModel, this will be the same as the data type, and samples are transferred one per array element.The following code illustrates transferring data for one pixel from
DataBufferdb1, whose storage layout is described byComponentSampleModelcsm1, toDataBufferdb2, whose storage layout is described byComponentSampleModelcsm2. The transfer will generally be more efficient than using getPixel/setPixel.ComponentSampleModel csm1, csm2; DataBufferInt db1, db2; csm2.setDataElements(x, y, csm1.getDataElements(x, y, null, db1), db2);Using getDataElements/setDataElements to transfer between twoDataBuffer/SampleModel pairs is legitimate if theSampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same.
setDataElements
public void setDataElements(int x,
int y,
int w,
int h,
java.lang.Object obj,
java.awt.image.DataBuffer data)
- Sets the data for a rectangle of pixels in the specified
DataBufferfrom a primitive array of type TransferType. For image data supported by the Java 2D API, this will be one of the dataTypes supported by java.awt.image.DataBuffer. Data in the array may be in a packed format, thus increasing efficiency for data transfers.The following code illustrates transferring data for a rectangular region of pixels from
DataBufferdb1, whose storage layout is described bySampleModelsm1, toDataBufferdb2, whose storage layout is described bySampleModelsm2. The transfer will generally be more efficient than using getPixels/setPixels.SampleModel sm1, sm2; DataBuffer db1, db2; sm2.setDataElements(x, y, w, h, sm1.getDataElements(x, y, w, h, null, db1), db2);Using getDataElements/setDataElements to transfer between twoDataBuffer/SampleModel pairs is legitimate if theSampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same.
setSample
public void setSample(int x,
int y,
int b,
float s,
java.awt.image.DataBuffer data)
- Sets a sample in the specified band for the pixel located at (x,y) in the
DataBufferusing afloatfor input.ArrayIndexOutOfBoundsExceptionmay be thrown if the coordinates are not in bounds.
setSample
public void setSample(int x,
int y,
int b,
double s,
java.awt.image.DataBuffer data)
- Sets a sample in the specified band for the pixel located at (x,y) in the
DataBufferusing adoublefor input.ArrayIndexOutOfBoundsExceptionmay be thrown if the coordinates are not in bounds.
getDataElements
public java.lang.Object getDataElements(int x, int y, java.lang.Object obj, java.awt.image.DataBuffer data)
- Returns data for a single pixel in a primitive array of type TransferType.
For a
ComponentSampleModel, this will be the same as the data type, and samples will be returned one per array element. Generally, obj should be passed in as null, so that theObjectwill be created automatically and will be of the right primitive data type.The following code illustrates transferring data for one pixel from
DataBufferdb1, whose storage layout is described byComponentSampleModelcsm1, toDataBufferdb2, whose storage layout is described byComponentSampleModelcsm2. The transfer will generally be more efficient than using getPixel/setPixel.ComponentSampleModel csm1, csm2; DataBufferInt db1, db2; csm2.setDataElements(x, y, csm1.getDataElements(x, y, null, db1), db2);Using getDataElements/setDataElements to transfer between twoDataBuffer/SampleModel pairs is legitimate if theSampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same.
getDataElements
public java.lang.Object getDataElements(int x, int y, int w, int h, java.lang.Object obj, java.awt.image.DataBuffer data)
- Returns the pixel data for the specified rectangle of pixels in a
primitive array of type TransferType. For image data supported by the Java
2D API, this will be one of the dataTypes supported by
java.awt.image.DataBuffer. Data may be returned in a packed format, thus
increasing efficiency for data transfers. Generally, obj should be passed
in as null, so that the
Objectwill be created automatically and will be of the right primitive data type.The following code illustrates transferring data for a rectangular region of pixels from
DataBufferdb1, whose storage layout is described bySampleModelsm1, toDataBufferdb2, whose storage layout is described bySampleModelsm2. The transfer will generally be more efficient than using getPixels/setPixels.SampleModel sm1, sm2; DataBuffer db1, db2; sm2.setDataElements(x, y, w, h, sm1.getDataElements(x, y, w, h, null, db1), db2);Using getDataElements/setDataElements to transfer between twoDataBuffer/SampleModel pairs is legitimate if theSampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same.
getSampleFloat
public float getSampleFloat(int x,
int y,
int b,
java.awt.image.DataBuffer data)
- Returns the sample in a specified band for the pixel located at (x,y) as a
float.ArrayIndexOutOfBoundsExceptionmay be thrown if the coordinates are not in bounds.
getSampleDouble
public double getSampleDouble(int x,
int y,
int b,
java.awt.image.DataBuffer data)
- Returns the sample in a specified band for a pixel located at (x,y) as a
double.ArrayIndexOutOfBoundsExceptionmay be thrown if the coordinates are not in bounds.
getPixels
public double[] getPixels(int x,
int y,
int w,
int h,
double[] dArray,
java.awt.image.DataBuffer data)
- Returns all samples for a rectangle of pixels in a
doublearray, one sample per array element.ArrayIndexOutOfBoundsExceptionmay be thrown if the coordinates are not in bounds.
createCompatibleSampleModel
public java.awt.image.SampleModel createCompatibleSampleModel(int w, int h)
- Creates a new
ComponentSampleModelwith the specified width and height. The newSampleModelwill have the same number of bands, storage data type, interleaving scheme, and pixel stride as thisSampleModel.
createSubsetSampleModel
public java.awt.image.SampleModel createSubsetSampleModel(int[] bands)
- This creates a new
ComponentSampleModelwith a subset of the bands of thisComponentSampleModel. The newComponentSampleModelcan be used with anyDataBufferthat the existingComponentSampleModelcan be used with. The newComponentSampleModel/DataBuffercombination will represent an image with a subset of the bands of the originalComponentSampleModel/DataBuffercombination.
createDataBuffer
public java.awt.image.DataBuffer createDataBuffer()
- Creates a
DataBufferthat corresponds to thisComponentSampleModel. TheDataBuffer's data type, number of banks, and size will be consistent with thisComponentSampleModel.
toString
public java.lang.String toString()
- Returns a
Stringcontaining the values of all valid fields.
getBufferSize
private long getBufferSize()
- Returns the size of the data buffer (in data elements) needed for a data
buffer that matches this
ComponentSampleModel.
JAIorderBands
private int[] JAIorderBands(int[] orig,
int step)
- Preserves band ordering with new step factor...
|
|||||||||
| Home >> All >> non_com >> media >> [ jai overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC