java.awt.image

Class SampleModel

Known Direct Subclasses:
ComponentSampleModel, MultiPixelPackedSampleModel, SinglePixelPackedSampleModel

public abstract class SampleModel
extends Object

This abstract class defines an interface for extracting samples of pixels in an image. All image data is expressed as a collection of pixels. Each pixel consists of a number of samples. A sample is a datum for one band of an image and a band consists of all samples of a particular type in an image. For example, a pixel might contain three samples representing its red, green and blue components. There are three bands in the image containing this pixel. One band consists of all the red samples from all pixels in the image. The second band consists of all the green samples and the remaining band consists of all of the blue samples. The pixel can be stored in various formats. For example, all samples from a particular band can be stored contiguously or all samples from a single pixel can be stored contiguously.

Subclasses of SampleModel specify the types of samples they can represent (e.g. unsigned 8-bit byte, signed 16-bit short, etc.) and may specify how the samples are organized in memory. In the Java 2D(tm) API, built-in image processing operators may not operate on all possible sample types, but generally will work for unsigned integral samples of 16 bits or less. Some operators support a wider variety of sample types.

A collection of pixels is represented as a Raster, which consists of a DataBuffer and a SampleModel. The SampleModel allows access to samples in the DataBuffer and may provide low-level information that a programmer can use to directly manipulate samples and pixels in the DataBuffer.

This class is generally a fall back method for dealing with images. More efficient code will cast the SampleModel to the appropriate subclass and extract the information needed to directly manipulate pixels in the DataBuffer.

See Also:
DataBuffer, Raster, ComponentSampleModel, PixelInterleavedSampleModel, BandedSampleModel, MultiPixelPackedSampleModel, SinglePixelPackedSampleModel

Field Summary

protected int
dataType
Data type of the DataBuffer storing the pixel data.
protected int
height
Height in pixels of the region of image data that this SampleModel describes.
protected int
numBands
Number of bands of the image data that this SampleModel describes.
protected int
width
Width in pixels of the region of image data that this SampleModel describes.

Constructor Summary

SampleModel(int dataType, int w, int h, int numBands)
Constructs a SampleModel with the specified parameters.

Method Summary

abstract SampleModel
createCompatibleSampleModel(int w, int h)
Creates a SampleModel which describes data in this SampleModel's format, but with a different width and height.
abstract DataBuffer
createDataBuffer()
Creates a DataBuffer that corresponds to this SampleModel.
abstract SampleModel
createSubsetSampleModel(bands[] )
Creates a new SampleModel with a subset of the bands of this SampleModel.
Object
getDataElements(int x, int y, int w, int h, Object obj, DataBuffer data)
Returns the pixel data for the specified rectangle of pixels in a primitive array of type TransferType.
abstract Object
getDataElements(int x, int y, Object obj, DataBuffer data)
Returns data for a single pixel in a primitive array of type TransferType.
int
getDataType()
Returns the data type of the DataBuffer storing the pixel data.
int
getHeight()
Returns the height in pixels.
int
getNumBands()
Returns the total number of bands of image data.
abstract int
getNumDataElements()
Returns the number of data elements needed to transfer a pixel via the getDataElements and setDataElements methods.
double[]
getPixel(int x, int y, dArray[] , DataBuffer data)
Returns the samples for the specified pixel in an array of double.
float[]
getPixel(int x, int y, fArray[] , DataBuffer data)
Returns the samples for the specified pixel in an array of float.
int[]
getPixel(int x, int y, iArray[] , DataBuffer data)
Returns the samples for a specified pixel in an int array, one sample per array element.
double[]
getPixels(int x, int y, int w, int h, dArray[] , DataBuffer data)
Returns all samples for a rectangle of pixels in a double array, one sample per array element.
float[]
getPixels(int x, int y, int w, int h, fArray[] , DataBuffer data)
Returns all samples for a rectangle of pixels in a float array, one sample per array element.
int[]
getPixels(int x, int y, int w, int h, iArray[] , DataBuffer data)
Returns all samples for a rectangle of pixels in an int array, one sample per array element.
abstract int
getSample(int x, int y, int b, DataBuffer data)
Returns the sample in a specified band for the pixel located at (x,y) as an int.
double
getSampleDouble(int x, int y, int b, 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, DataBuffer data)
Returns the sample in a specified band for the pixel located at (x,y) as a float.
abstract int[]
getSampleSize()
Returns the size in bits of samples for all bands.
abstract int
getSampleSize(int band)
Returns the size in bits of samples for the specified band.
double[]
getSamples(int x, int y, int w, int h, int b, dArray[] , DataBuffer data)
Returns the samples for a specified band for a specified rectangle of pixels in a double array, one sample per array element.
float[]
getSamples(int x, int y, int w, int h, int b, fArray[] , DataBuffer data)
Returns the samples for a specified band for the specified rectangle of pixels in a float array, one sample per array element.
int[]
getSamples(int x, int y, int w, int h, int b, 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
getTransferType()
Returns the TransferType used to transfer pixels via the getDataElements and setDataElements methods.
int
getWidth()
Returns the width in pixels.
void
setDataElements(int x, int y, int w, int h, Object obj, DataBuffer data)
Sets the data for a rectangle of pixels in the specified DataBuffer from a primitive array of type TransferType.
abstract 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, dArray[] , DataBuffer data)
Sets a pixel in the DataBuffer using a double array of samples for input.
void
setPixel(int x, int y, fArray[] , DataBuffer data)
Sets a pixel in the DataBuffer using a float array of samples for input.
void
setPixel(int x, int y, 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, dArray[] , DataBuffer data)
Sets all samples for a rectangle of pixels from a double array containing one sample per array element.
void
setPixels(int x, int y, int w, int h, fArray[] , DataBuffer data)
Sets all samples for a rectangle of pixels from a float array containing one sample per array element.
void
setPixels(int x, int y, int w, int h, 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, double s, 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, DataBuffer data)
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using a float for input.
abstract 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, dArray[] , DataBuffer data)
Sets the samples in the specified band for the specified rectangle of pixels from a double array containing one sample per array element.
void
setSamples(int x, int y, int w, int h, int b, fArray[] , DataBuffer data)
Sets the samples in the specified band for the specified rectangle of pixels from a float array containing one sample per array element.
void
setSamples(int x, int y, int w, int h, int b, 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.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

dataType

protected int dataType
Data type of the DataBuffer storing the pixel data.
See Also:
DataBuffer

height

protected int height
Height in pixels of the region of image data that this SampleModel describes.

numBands

protected int numBands
Number of bands of the image data that this SampleModel describes.

width

protected int width
Width in pixels of the region of image data that this SampleModel describes.

Constructor Details

SampleModel

public SampleModel(int dataType,
                   int w,
                   int h,
                   int numBands)
Constructs a SampleModel with the specified parameters.
Parameters:
dataType - The data type of the DataBuffer storing the pixel data.
w - The width (in pixels) of the region of image data.
h - The height (in pixels) of the region of image data.
numBands - The number of bands of the image data.
Throws:
IllegalArgumentException - if w or h is not greater than 0
IllegalArgumentException - if the product of w and h is greater than Integer.MAX_VALUE
IllegalArgumentException - if dataType is not one of the supported data types

Method Details

createCompatibleSampleModel

public abstract SampleModel createCompatibleSampleModel(int w,
                                                        int h)
Creates a SampleModel which describes data in this SampleModel's format, but with a different width and height.
Parameters:
w - the width of the image data
h - the height of the image data
Returns:
a SampleModel describing the same image data as this SampleModel, but with a different size.
Usages and Demos :

View More Examples of createCompatibleSampleModel(int w,int h)
   1: import java.awt.image.RenderedImage;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.SinglePixelPackedSampleModel;
   4:         ...
   5: 
   6:         SampleModel sm = fixSampleModel(tile, xStep, yStep, 
   7:                                         tiledRegion.width,
   8:         ...
   9:             }
  10:             sm = sm.createCompatibleSampleModel(xSz, ySz);
  11:             raster = Raster.createWritableRaster
  12:         ...
  13:     
  14:     protected static SampleModel fixSampleModel(RenderedImage src,

View Full Code Here
   1: import java.awt.image.DataBufferInt;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.SinglePixelPackedSampleModel;
   4:         ...
   5: 
   6:     protected static SampleModel fixSampleModel(CachableRed src,
   7:                                                 Rectangle   bounds) {
   8:         ...
   9: 
  10:         SampleModel sm = src.getSampleModel();
  11:         int w = sm.getWidth();
  12:         ...
  13: 
  14:         return sm.createCompatibleSampleModel(w, h);

View Full Code Here

createDataBuffer

public abstract DataBuffer createDataBuffer()
Creates a DataBuffer that corresponds to this SampleModel. The DataBuffer's width and height will match this SampleModel's.
Returns:
a DataBuffer corresponding to this SampleModel.

createSubsetSampleModel

public abstract SampleModel createSubsetSampleModel(bands[] )
Creates a new SampleModel with a subset of the bands of this SampleModel.
Parameters:
Returns:
a SampleModel with a subset of bands of this SampleModel.

getDataElements

public Object getDataElements(int x,
                              int y,
                              int w,
                              int h,
                              Object obj,
                              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 DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE. 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 Object will 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 DataBuffer db1, whose storage layout is described by SampleModel sm1, to DataBuffer db2, whose storage layout is described by SampleModel sm2. 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 two DataBuffer/SampleModel pairs is legitimate if the SampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same.

If obj is non-null, it should be a primitive array of type TransferType. Otherwise, a ClassCastException is thrown. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds, or if obj is non-null and is not large enough to hold the pixel data.

Parameters:
x - The minimum X coordinate of the pixel rectangle.
y - The minimum Y coordinate of the pixel rectangle.
w - The width of the pixel rectangle.
h - The height of the pixel rectangle.
obj - If non-null, a primitive array in which to return the pixel data.
data - The DataBuffer containing the image data.
Returns:
the data elements for the specified region of pixels.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if obj is too small to hold the output.

getDataElements

public abstract Object getDataElements(int x,
                                       int y,
                                       Object obj,
                                       DataBuffer data)
Returns data for a single pixel in a primitive array of type TransferType. For image data supported by the Java 2D API, this will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE. 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 Object will be created automatically and will be of the right primitive data type.

The following code illustrates transferring data for one pixel from DataBuffer db1, whose storage layout is described by SampleModel sm1, to DataBuffer db2, whose storage layout is described by SampleModel sm2. The transfer will generally be more efficient than using getPixel/setPixel.

 	     SampleModel sm1, sm2;
	     DataBuffer db1, db2;
 	     sm2.setDataElements(x, y, sm1.getDataElements(x, y, null, db1), db2);
 
Using getDataElements/setDataElements to transfer between two DataBuffer/SampleModel pairs is legitimate if the SampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same.

If obj is non-null, it should be a primitive array of type TransferType. Otherwise, a ClassCastException is thrown. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds, or if obj is non-null and is not large enough to hold the pixel data.

Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
obj - If non-null, a primitive array in which to return the pixel data.
data - The DataBuffer containing the image data.
Returns:
the data elements for the specified pixel.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if obj is too small to hold the output.

getDataType

public final int getDataType()
Returns the data type of the DataBuffer storing the pixel data.
Returns:
the data type.
Usages and Demos :

View More Examples of getDataType()
   1: import java.awt.image.DataBuffer;
   2: import java.awt.image.SampleModel;
   3: import java.io.ObjectStreamException;
   4:         ...
   5: 
   6:     public static SampleDimensionType getEnum(final SampleModel model, final int band)
   7:         throws IllegalArgumentException
   8:         ...
   9:         boolean signed = true;
  10:         switch (model.getDataType()) {
  11:             case DataBuffer.TYPE_DOUBLE: return DOUBLE;

View Full Code Here
   1: import java.awt.image.DataBufferUShort;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5:     
   6:     protected SampleModel getStreamSampleModel(final int imageIndex, final ImageReadParam param)
   7:             throws IOException
   8:         ...
   9:         }
  10:         SampleModel streamModel = getRawImageType(imageIndex).getSampleModel();
  11:         streamModel = streamModel.createCompatibleSampleModel(streamImageSize.width,
  12:         ...
  13:         final int        streamHeight = streamModel.getHeight();
  14:         final int      streamDataType = streamModel.getDataType();

View Full Code Here
   1: import java.awt.image.ColorModel;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.BufferedImage;
   4:         ...
   5:     
   6:     protected SampleModel getStreamSampleModel(final int imageIndex, final ImageReadParam param)
   7:             throws IOException
   8:         ...
   9:         }
  10:         SampleModel streamModel = getRawImageType(imageIndex).getSampleModel();
  11:         streamModel = streamModel.createCompatibleSampleModel(streamImageSize.width,
  12:         ...
  13:         final int        streamHeight = streamModel.getHeight();
  14:         final int      streamDataType = streamModel.getDataType();

View Full Code Here
   1: import java.awt.image.RenderedImage;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.WritableRenderedImage;
   4:         ...
   5:     public Object evaluate(final DirectPosition point) throws CannotEvaluateException {
   6:         final int dataType = image.getSampleModel().getDataType();
   7:         switch (dataType) {
   8:         ...
   9:             final Raster raster = image.getTile(image.XToTileX(x), image.YToTileY(y));
  10:             final int  datatype = image.getSampleModel().getDataType();
  11:             final StringBuffer  buffer = new StringBuffer();
  12:         ...
  13:         ColorModel  colors = targetBands[visibleBand].getColorModel(visibleBand, numBands);
  14:         SampleModel  model = colors.createCompatibleSampleModel(layout.getTileWidth (image),

View Full Code Here
   1: import java.awt.image.Raster;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5:         decodeImage(interlaceMethod == 1);
   6:         SampleModel sm = theTile.getSampleModel();
   7:     ColorModel  cm;
   8:         ...
   9:                               DataBuffer.TYPE_INT);
  10:     public static ColorModel createComponentColorModel(SampleModel sm) {
  11:         ...
  12:         int type = sm.getDataType();

View Full Code Here

getHeight

public final int getHeight()
Returns the height in pixels.
Returns:
the height in pixels of the region of image data that this SampleModel describes.
Usages and Demos :

View More Examples of getHeight()
   1: import java.awt.image.Raster;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.SinglePixelPackedSampleModel;
   4:         ...
   5: 
   6:     public static boolean is_INT_PACK_COMP(SampleModel sm) {
   7:         if(!(sm instanceof SinglePixelPackedSampleModel)) return false;
   8:         ...
   9:         final int width      = wr.getWidth();
  10:         final int height     = wr.getHeight();
  11:         final int scanStride = sm.getScanlineStride();
  12:         ...
  13:         ColorModel  srcCM = src.getColorModel();
  14:         SampleModel srcSM = src.getSampleModel();

View Full Code Here
   1: import java.awt.image.Raster;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.SinglePixelPackedSampleModel;
   4:         ...
   5: 
   6:     public static boolean is_INT_PACK_COMP(SampleModel sm) {
   7:         if(!(sm instanceof SinglePixelPackedSampleModel)) return false;
   8:         ...
   9:         final int width      = wr.getWidth();
  10:         final int height     = wr.getHeight();
  11:         final int scanStride = sm.getScanlineStride();
  12:         ...
  13:         ColorModel  srcCM = src.getColorModel();
  14:         SampleModel srcSM = src.getSampleModel();

View Full Code Here
   1: import java.awt.image.RenderedImage;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5:         
   6:         final SampleModel sm=image.getSampleModel();
   7:         final int dataType=DataBuffer.TYPE_SHORT;
   8:         ...
   9:                     dataType);
  10:             final SampleModel newSm = new ComponentSampleModelJAI(
  11:                     dataType,
  12:         ...
  13:                     sm.getWidth(),
  14:                     sm.getHeight(),

View Full Code Here
   1: import java.awt.image.RenderedImage;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5:             g2d.setComposite(AlphaComposite.Clear);
   6:             g2d.fillRect(0, 0, bi.getWidth(), bi.getHeight());
   7:             g2d.dispose();
   8:         ...
   9: 
  10:         SampleModel sm = rootCR.getSampleModel();
  11:         int         w  = offScreenWidth;
  12:         ...
  13:         int tw = sm.getWidth();
  14:         int th = sm.getHeight();

View Full Code Here
   1: import java.awt.image.Raster;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.SinglePixelPackedSampleModel;
   4:         ...
   5:         ColorModel cm  = fixColorModel(src);
   6:         SampleModel sm = src.getSampleModel();
   7:         int tw = sm.getWidth();
   8:         ...
   9:         int th = sm.getHeight();
  10:         if (tw > myBounds.width)  tw = myBounds.width;
  11:         ...
  12:         final int w = src.getWidth();
  13:         final int h = src.getHeight();

View Full Code Here

getNumBands

public final int getNumBands()
Returns the total number of bands of image data.
Returns:
the number of bands of image data that this SampleModel describes.
Usages and Demos :

View More Examples of getNumBands()
   1: import jp.ujihara.java.awt.image.RenderedImage;
   2: import jp.ujihara.java.awt.image.SampleModel;
   3: 
   4:         ...
   5:   protected ColorModel colorModel;
   6:   protected SampleModel sampleModel;
   7: 
   8:         ...
   9:   {
  10:     return sampleModel.getNumBands();
  11:   }

View Full Code Here
   1: import java.awt.image.RenderedImage;
   2: import java.awt.image.SampleModel;
   3: import java.text.NumberFormat;
   4:         ...
   5:         renderer.formatter = samples.getNumberFormat();
   6:         final SampleModel model = image.getSampleModel();
   7:         ...
   8:         final int      numBands = model.getNumBands();
   9:         final Integer  maximum  = new Integer(numBands);

View Full Code Here
   1: import java.awt.image.Raster;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.SinglePixelPackedSampleModel;
   4:         ...
   5:         ColorModel  srcCM = src.getColorModel();
   6:         SampleModel srcSM = src.getSampleModel();
   7: 
   8:         ...
   9:             float [][] matrix = null;
  10:             switch (srcSM.getNumBands()) {
  11:             case 1:
  12:         ...
  13:             default:
  14:                 matrix = new float[srcSM.getNumBands()][4];

View Full Code Here
   1: import java.awt.image.Raster;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.SinglePixelPackedSampleModel;
   4:         ...
   5: 
   6:     public static boolean is_INT_PACK_COMP(SampleModel sm) {
   7:         if(!(sm instanceof SinglePixelPackedSampleModel)) return false;
   8:         ...
   9:         ColorModel  srcCM = src.getColorModel();
  10:         SampleModel srcSM = src.getSampleModel();
  11: 
  12:         ...
  13:             float [][] matrix = null;
  14:             switch (srcSM.getNumBands()) {

View Full Code Here
   1: import java.awt.image.Raster;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.SinglePixelPackedSampleModel;
   4:         ...
   5: 
   6:     public static boolean is_INT_PACK_COMP(SampleModel sm) {
   7:         if(!(sm instanceof SinglePixelPackedSampleModel)) return false;
   8:         ...
   9:         ColorModel  srcCM = src.getColorModel();
  10:         SampleModel srcSM = src.getSampleModel();
  11: 
  12:         ...
  13:             float [][] matrix = null;
  14:             switch (srcSM.getNumBands()) {

View Full Code Here

getNumDataElements

public abstract int getNumDataElements()
Returns the number of data elements needed to transfer a pixel via the getDataElements and setDataElements methods. When pixels are transferred via these methods, they may be transferred in a packed or unpacked format, depending on the implementation of the SampleModel. Using these methods, pixels are transferred as an array of getNumDataElements() elements of a primitive type given by getTransferType(). The TransferType may or may not be the same as the storage DataType.
Returns:
the number of data elements.

getPixel

public double[] getPixel(int x,
                         int y,
                         dArray[] ,
                         DataBuffer data)
Returns the samples for the specified pixel in an array of double. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
data - The DataBuffer containing the image data.
Returns:
the samples for the specified pixel.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if dArray is too small to hold the output.
See Also:
setPixel(int, int, double[], DataBuffer)

getPixel

public float[] getPixel(int x,
                        int y,
                        fArray[] ,
                        DataBuffer data)
Returns the samples for the specified pixel in an array of float. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
data - The DataBuffer containing the image data.
Returns:
the samples for the specified pixel.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if fArray is too small to hold the output.
See Also:
setPixel(int, int, float[], DataBuffer)

getPixel

public int[] getPixel(int x,
                      int y,
                      iArray[] ,
                      DataBuffer data)
Returns the samples for a specified pixel in an int array, one sample per array element. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
Parameters:
data - The DataBuffer containing the image data
Returns:
the samples for the specified pixel.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if iArray is too small to hold the output.
See Also:
setPixel(int, int, int[], DataBuffer)

getPixels

public double[] getPixels(int x,
                          int y,
                          int w,
                          int h,
                          dArray[] ,
                          DataBuffer data)
Returns all samples for a rectangle of pixels in a double array, one sample per array element. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
data - The DataBuffer containing the image data.
Returns:
the samples for the specified region of pixels.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if dArray is too small to hold the output.
See Also:
setPixels(int, int, int, int, double[], DataBuffer)

getPixels

public float[] getPixels(int x,
                         int y,
                         int w,
                         int h,
                         fArray[] ,
                         DataBuffer data)
Returns all samples for a rectangle of pixels in a float array, one sample per array element. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
data - The DataBuffer containing the image data.
Returns:
the samples for the specified region of pixels.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if fArray is too small to hold the output.
See Also:
setPixels(int, int, int, int, float[], DataBuffer)

getPixels

public int[] getPixels(int x,
                       int y,
                       int w,
                       int h,
                       iArray[] ,
                       DataBuffer data)
Returns all samples for a rectangle of pixels in an int array, one sample per array element. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
data - The DataBuffer containing the image data.
Returns:
the samples for the specified region of pixels.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if iArray is too small to hold the output.
See Also:
setPixels(int, int, int, int, int[], DataBuffer)

getSample

public abstract int getSample(int x,
                              int y,
                              int b,
                              DataBuffer data)
Returns the sample in a specified band for the pixel located at (x,y) as an int. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
Returns:
the sample in a specified band for the specified pixel.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates or the band index are not in bounds.

getSampleDouble

public double getSampleDouble(int x,
                              int y,
                              int b,
                              DataBuffer data)
Returns the sample in a specified band for a pixel located at (x,y) as a double. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
Returns:
the sample in a specified band for the specified pixel.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates or the band index are not in bounds.

getSampleFloat

public float getSampleFloat(int x,
                            int y,
                            int b,
                            DataBuffer data)
Returns the sample in a specified band for the pixel located at (x,y) as a float. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
Returns:
the sample in a specified band for the specified pixel.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates or the band index are not in bounds.

getSampleSize

public abstract int[] getSampleSize()
Returns the size in bits of samples for all bands.
Returns:
the size of samples for all bands.
Usages and Demos :

View More Examples of getSampleSize()
   1: import java.awt.image.DataBufferUShort;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.renderable.ParameterBlock;
   4:         ...
   5:     protected int compression;
   6:     protected SampleModel sampleModel;
   7:     protected int[] sampleSize;
   8:         ...
   9:         numBands = sampleModel.getNumBands();
  10:         sampleSize = sampleModel.getSampleSize(); 
  11: 
  12:         ...
  13:         numBands = sampleModel.getNumBands();
  14:         sampleSize = sampleModel.getSampleSize(); 

View Full Code Here
   1: import java.awt.image.RenderedImage;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5: 
   6:         SampleModel sampleModel = im.getSampleModel();
   7: 
   8:         ...
   9:     int sampleSize[] = sampleModel.getSampleSize();
  10:         for(int i = 1; i < sampleSize.length; i++) {

View Full Code Here

getSampleSize

public abstract int getSampleSize(int band)
Returns the size in bits of samples for the specified band.
Parameters:
band - the specified band
Returns:
the size of the samples of the specified band.
Usages and Demos :

View More Examples of getSampleSize(int band)
   1: import java.awt.image.DataBuffer;
   2: import java.awt.image.SampleModel;
   3: import java.io.ObjectStreamException;
   4:         ...
   5: 
   6:     public static SampleDimensionType getEnum(final SampleModel model, final int band)
   7:         throws IllegalArgumentException
   8:         ...
   9:             case DataBuffer.TYPE_BYTE: {
  10:                 switch (model.getSampleSize(band)) {
  11:                     case  1: return BIT;

View Full Code Here

getSamples

public double[] getSamples(int x,
                           int y,
                           int w,
                           int h,
                           int b,
                           dArray[] ,
                           DataBuffer data)
Returns the samples for a specified band for a specified rectangle of pixels in a double array, one sample per array element. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
data - The DataBuffer containing the image data.
Returns:
the samples for the specified band for the specified region of pixels.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates or the band index are not in bounds, or if dArray is too small to hold the output.
See Also:
setSamples(int, int, int, int, int, double[], DataBuffer)

getSamples

public float[] getSamples(int x,
                          int y,
                          int w,
                          int h,
                          int b,
                          fArray[] ,
                          DataBuffer data)
Returns the samples for a specified band for the specified rectangle of pixels in a float array, one sample per array element. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
data - The DataBuffer containing the image data.
Returns:
the samples for the specified band for the specified region of pixels.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates or the band index are not in bounds, or if fArray is too small to hold the output.
See Also:
setSamples(int, int, int, int, int, float[], DataBuffer)

getSamples

public int[] getSamples(int x,
                        int y,
                        int w,
                        int h,
                        int b,
                        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. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
data - The DataBuffer containing the image data.
Returns:
the samples for the specified band for the specified region of pixels.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates or the band index are not in bounds, or if iArray is too small to hold the output.
See Also:
setSamples(int, int, int, int, int, int[], DataBuffer)

getTransferType

public int getTransferType()
Returns the TransferType used to transfer pixels via the getDataElements and setDataElements methods. When pixels are transferred via these methods, they may be transferred in a packed or unpacked format, depending on the implementation of the SampleModel. Using these methods, pixels are transferred as an array of getNumDataElements() elements of a primitive type given by getTransferType(). The TransferType may or may not be the same as the storage DataType. The TransferType will be one of the types defined in DataBuffer.
Returns:
the transfer type.
Usages and Demos :

View More Examples of getTransferType()
   1: import java.awt.image.DataBuffer;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5:     
   6:     public SampleModel createCompatibleSampleModel(final int width, final int height) {
   7:         return new BandedSampleModel(transferType, width, height, numBands);
   8:         ...
   9:     
  10:     public boolean isCompatibleSampleModel(final SampleModel sm) {
  11:         return (sm instanceof ComponentSampleModel)                  &&
  12:         ...
  13:                 sm.getTransferType()                 == transferType &&

View Full Code Here
   1: import java.awt.image.Raster;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5:     
   6:     public SampleModel createCompatibleSampleModel(final int width, final int height) {
   7:         return new BandedSampleModel(transferType, width, height, numBands);
   8:         ...
   9:     
  10:     public boolean isCompatibleSampleModel(final SampleModel sm) {
  11:         return (sm instanceof ComponentSampleModel)                  &&
  12:         ...
  13:                 sm.getTransferType()                 == transferType &&

View Full Code Here
   1: import java.awt.image.Raster;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.SinglePixelPackedSampleModel;
   4:         ...
   5: 
   6:     public WritableRaster createTile(SampleModel sampleModel, Point location) {
   7: 
   8:         ...
   9: 
  10:         int type = sampleModel.getTransferType();
  11:         long numBanks = 0;

View Full Code Here
   1: import java.awt.image.Raster;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.SinglePixelPackedSampleModel;
   4:         ...
   5: 
   6:     public WritableRaster createTile(SampleModel sampleModel, Point location) {
   7: 
   8:         ...
   9: 
  10:         int type = sampleModel.getTransferType();
  11:         long numBanks = 0;

View Full Code Here
   1: import java.awt.image.RenderedImage;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.renderable.ParameterBlock;
   4:         ...
   5: 
   6:         final SampleModel sm = source.getSampleModel();
   7: 
   8:         ...
   9:                 .getInstance(), false, false, cm.getTransparency(), cm
  10:                 .getTransferType());
  11:         final ParameterBlockJAI pbjCC = new ParameterBlockJAI("colorconvert");
  12:         ...
  13: 
  14:         if (sourceImage.getSampleModel().getTransferType() != DataBuffer.TYPE_BYTE) {

View Full Code Here

getWidth

public final int getWidth()
Returns the width in pixels.
Returns:
the width in pixels of the region of image data that this SampleModel describes.
Usages and Demos :

View More Examples of getWidth()
   1: import java.awt.image.Raster;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5: 
   6:         SampleModel sm     = src.getSampleModel();
   7:         ColorModel  srcCM  = src.getColorModel();
   8:         ...
   9:                 dstSM = (PixelInterleavedSampleModel)wr.getSampleModel();
  10:                 SampleModel smna = new PixelInterleavedSampleModel
  11:                     (dstSM.getDataType(),    
  12:         ...
  13:                      dstSM.getWidth(),       dstSM.getHeight(),

View Full Code Here
   1: import java.awt.image.Raster;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5: 
   6:         SampleModel sm = fixSampleModel(src, cm, myBounds);
   7: 
   8:         ...
   9:         zr.zeroRect(new Rectangle(wr.getMinX(), wr.getMinY(), 
  10:                                   wr.getWidth(), wr.getHeight()));
  11:         genRect(wr);
  12:         ...
  13: 
  14:     protected SampleModel fixSampleModel(CachableRed src,

View Full Code Here
   1: import java.awt.image.Raster;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.WritableRaster;
   4:         ...
   5: 
   6:         SampleModel sm = fixSampleModel(src, cm, myBounds);
   7: 
   8:         ...
   9:         zr.zeroRect(new Rectangle(wr.getMinX(), wr.getMinY(), 
  10:                                   wr.getWidth(), wr.getHeight()));
  11:     }
  12:         ...
  13: 
  14:     protected static SampleModel fixSampleModel(CachableRed src,

View Full Code Here
   1: import java.awt.image.Raster;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.SinglePixelPackedSampleModel;
   4:         ...
   5: 
   6:     public static boolean is_INT_PACK_COMP(SampleModel sm) {
   7:         if(!(sm instanceof SinglePixelPackedSampleModel)) return false;
   8:         ...
   9:         final int pixels[]   = db.getBankData()[0];
  10:         final int width      = wr.getWidth();
  11:         final int height     = wr.getHeight();
  12:         ...
  13:         ColorModel  srcCM = src.getColorModel();
  14:         SampleModel srcSM = src.getSampleModel();

View Full Code Here
   1: import java.awt.image.Raster;
   2: import java.awt.image.SampleModel;
   3: import java.awt.image.SinglePixelPackedSampleModel;
   4:         ...
   5: 
   6:     public static boolean is_INT_PACK_COMP(SampleModel sm) {
   7:         if(!(sm instanceof SinglePixelPackedSampleModel)) return false;
   8:         ...
   9:         final int pixels[]   = db.getBankData()[0];
  10:         final int width      = wr.getWidth();
  11:         final int height     = wr.getHeight();
  12:         ...
  13:         ColorModel  srcCM = src.getColorModel();
  14:         SampleModel srcSM = src.getSampleModel();

View Full Code Here

setDataElements

public void setDataElements(int x,
                            int y,
                            int w,
                            int h,
                            Object obj,
                            DataBuffer data)
Sets the data for a rectangle of pixels in the specified DataBuffer from a primitive array of type TransferType. For image data supported by the Java 2D API, this will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE. 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 DataBuffer db1, whose storage layout is described by SampleModel sm1, to DataBuffer db2, whose storage layout is described by SampleModel sm2. 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 two DataBuffer/SampleModel pairs is legitimate if the SampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same.

obj must be a primitive array of type TransferType. Otherwise, a ClassCastException is thrown. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds, or if obj is not large enough to hold the pixel data.

Parameters:
x - The minimum X coordinate of the pixel rectangle.
y - The minimum Y coordinate of the pixel rectangle.
w - The width of the pixel rectangle.
h - The height of the pixel rectangle.
obj - A primitive array containing pixel data.
data - The DataBuffer containing the image data.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if obj is too small to hold the input.

setDataElements

public abstract 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. For image data supported by the Java 2D API, this will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE. Data in the array may be in a packed format, thus increasing efficiency for data transfers.

The following code illustrates transferring data for one pixel from DataBuffer db1, whose storage layout is described by SampleModel sm1, to DataBuffer db2, whose storage layout is described by SampleModel sm2. The transfer will generally be more efficient than using getPixel/setPixel.

 	     SampleModel sm1, sm2;
	     DataBuffer db1, db2;
 	     sm2.setDataElements(x, y, sm1.getDataElements(x, y, null, db1),
                           db2);
 
Using getDataElements/setDataElements to transfer between two DataBuffer/SampleModel pairs is legitimate if the SampleModels have the same number of bands, corresponding bands have the same number of bits per sample, and the TransferTypes are the same.

obj must be a primitive array of type TransferType. Otherwise, a ClassCastException is thrown. An ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds, or if obj is not large enough to hold the pixel data.

Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
obj - A primitive array containing pixel data.
data - The DataBuffer containing the image data.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if obj is too small to hold the input.

setPixel

public void setPixel(int x,
                     int y,
                     dArray[] ,
                     DataBuffer data)
Sets a pixel in the DataBuffer using a double array of samples for input.
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
data - The DataBuffer containing the image data.
Throws:
NullPointerException - if dArray or data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if fArray is too small to hold the input.
See Also:
getPixel(int, int, double[], DataBuffer)

setPixel

public void setPixel(int x,
                     int y,
                     fArray[] ,
                     DataBuffer data)
Sets a pixel in the DataBuffer using a float array of samples for input. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
data - The DataBuffer containing the image data.
Throws:
NullPointerException - if fArray or data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if fArray is too small to hold the input.
See Also:
getPixel(int, int, float[], DataBuffer)

setPixel

public void setPixel(int x,
                     int y,
                     iArray[] ,
                     DataBuffer data)
Sets a pixel in the DataBuffer using an int array of samples for input. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
Parameters:
x - The X coordinate of the pixel location.
y - The Y coordinate of the pixel location.
data - The DataBuffer containing the image data.
Throws:
NullPointerException - if iArray or data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if iArray is too small to hold the input.
See Also:
getPixel(int, int, int[], DataBuffer)

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      dArray[] ,
                      DataBuffer data)
Sets all samples for a rectangle of pixels from a double array containing one sample per array element. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
data - The DataBuffer containing the image data.
Throws:
NullPointerException - if dArray or data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if dArray is too small to hold the input.
See Also:
getPixels(int, int, int, int, double[], DataBuffer)

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      fArray[] ,
                      DataBuffer data)
Sets all samples for a rectangle of pixels from a float array containing one sample per array element. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
data - The DataBuffer containing the image data.
Throws:
NullPointerException - if fArray or data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if fArray is too small to hold the input.
See Also:
getPixels(int, int, int, int, float[], DataBuffer)

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      iArray[] ,
                      DataBuffer data)
Sets all samples for a rectangle of pixels from an int array containing one sample per array element. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
data - The DataBuffer containing the image data.
Throws:
NullPointerException - if iArray or data is null.
ArrayIndexOutOfBoundsException - if the coordinates are not in bounds, or if iArray is too small to hold the input.
See Also:
getPixels(int, int, int, int, int[], DataBuffer)

setSample

public void setSample(int x,
                      int y,
                      int b,
                      double s,
                      DataBuffer data)
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using a double for input. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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 a double.
data - The DataBuffer containing the image data.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates or the band index are not in bounds.

setSample

public void setSample(int x,
                      int y,
                      int b,
                      float s,
                      DataBuffer data)
Sets a sample in the specified band for the pixel located at (x,y) in the DataBuffer using a float for input. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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 a float.
data - The DataBuffer containing the image data.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates or the band index are not in bounds.

setSample

public abstract 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. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
Throws:
NullPointerException - if data is null.
ArrayIndexOutOfBoundsException - if the coordinates or the band index are not in bounds.

setSamples

public void setSamples(int x,
                       int y,
                       int w,
                       int h,
                       int b,
                       dArray[] ,
                       DataBuffer data)
Sets the samples in the specified band for the specified rectangle of pixels from a double array containing one sample per array element. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
data - The DataBuffer containing the image data.
Throws:
NullPointerException - if dArray or data is null.
ArrayIndexOutOfBoundsException - if the coordinates or the band index are not in bounds, or if dArray is too small to hold the input.
See Also:
getSamples(int, int, int, int, int, double[], DataBuffer)

setSamples

public void setSamples(int x,
                       int y,
                       int w,
                       int h,
                       int b,
                       fArray[] ,
                       DataBuffer data)
Sets the samples in the specified band for the specified rectangle of pixels from a float array containing one sample per array element. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
data - The DataBuffer containing the image data.
Throws:
NullPointerException - if fArray or data is null.
ArrayIndexOutOfBoundsException - if the coordinates or the band index are not in bounds, or if fArray is too small to hold the input.
See Also:
getSamples(int, int, int, int, int, float[], DataBuffer)

setSamples

public void setSamples(int x,
                       int y,
                       int w,
                       int h,
                       int b,
                       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. ArrayIndexOutOfBoundsException may be thrown if the coordinates are not in bounds.
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.
data - The DataBuffer containing the image data.
Throws:
NullPointerException - if iArray or data is null.
ArrayIndexOutOfBoundsException - if the coordinates or the band index are not in bounds, or if iArray is too small to hold the input.
See Also:
getSamples(int, int, int, int, int, int[], DataBuffer)