home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-20 | 28.5 KB | 928 lines |
- /*
- * @(#)SampleModel.java 1.13 98/03/18
- *
- * Copyright 1997, 1998 by Sun Microsystems, Inc.,
- * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
- * All rights reserved.
- *
- * This software is the confidential and proprietary information
- * of Sun Microsystems, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Sun.
- */
-
- /* ****************************************************************
- ******************************************************************
- ******************************************************************
- *** COPYRIGHT (c) Eastman Kodak Company, 1997
- *** As an unpublished work pursuant to Title 17 of the United
- *** States Code. All rights reserved.
- ******************************************************************
- ******************************************************************
- ******************************************************************/
-
- package java.awt.image;
-
- /**
- * This abstract class defines an interface for extracting samples of
- * an image without knowing how the underlying data is stored in a
- * DataBuffer. All image data is expressed as a collection of pixels.
- * Each pixel consists of a number of samples. A sample is a collection
- * of data for one band of an image.
- *
- * 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 DataBuffer
- * @see ComponentSampleModel
- * @see BandedSampleModel
- * @see MultiPixelPackedSampleModel
- * @see SinglePixelPackedSampleModel
- */
-
- public abstract class SampleModel
- {
-
- /** Width of the region of image data that this SampleModel describes. */
- protected int width;
-
- /** Height of the region of image data that this SampleModel describes. */
- protected int height;
-
- /** number of bands of the inage data that this SampleModel describes. */
- protected int numBands;
-
- /** Data type of the underlying pixel data. */
- protected int dataType;
-
- /** minimum sample value for all bands. */
- private float minMinSampleValue;
-
- /** maximum sample value for all bands. */
- private float maxMaxSampleValue;
-
- /** minimum sample values for various bands. */
- private float minSampleValue[];
-
- /** maximum sample values for various bands. */
- private float maxSampleValue[];
-
- static private native void initIDs();
- static {
- ColorModel.loadLibraries();
- initIDs();
- }
-
- /**
- * Constructs a SampleModel with the specified parameters.
- * @param dataType the data type of the underlying pixel data.
- * @param w The width (in pixels) of the region of image data.
- * @param h The height (in pixels) of the region of image data.
- * @param numBands The number of bands of the image data.
- */
- public SampleModel(int dataType, int w, int h, int numBands)
- {
- float size = (float)w*h;
- if (w <= 0 || h <= 0) {
- throw new IllegalArgumentException("Width ("+w+") and height ("+
- height+") must be > 0");
- }
- if (size >= Integer.MAX_VALUE) {
- throw new IllegalArgumentException("Dimensions (width="+w+
- " height="+h+") are too large");
- }
- this.dataType = dataType;
- this.width = w;
- this.height = h;
- this.numBands = numBands;
- }
-
- /** Returns the width in pixels. */
- final public int getWidth() {
- return width;
- }
-
- /** Returns the height in pixels. */
- final public int getHeight() {
- return height;
- }
-
- /** Returns the total number of bands of image data. */
- final public int getNumBands() {
- return numBands;
- }
-
- /** Returns the number of data elements needed to store a pixel. */
- public abstract int getNumDataElements();
-
- /** Returns the data type. */
- final public int getDataType() {
- return dataType;
- }
-
- /** Returns the transfer type of the data. */
- public abstract int getTransferType();
-
- /**
- * Returns the samples for a specified pixel in an array of int.
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param iArray If non-null, returns the samples in this array.
- * @param data The DataBuffer containing the image data.
- */
- public int[] getPixel(int x, int y, int iArray[], DataBuffer data) {
-
- int pixels[];
-
- if (iArray != null)
- pixels = iArray;
- else
- pixels = new int[numBands];
-
- for (int i=0; i<numBands; i++) {
- pixels[i] = getSample(x, y, i, data);
- }
-
- return pixels;
- }
-
- /**
- * 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.
- * <pre>
- * SampleModel sm1, sm2;
- * DataBuffer db1, db2;
- * sm2.setPixelData(x, y, sm1.getPixelData(x, y, null, db1), db2);
- * </pre>
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param obj If non-null, returns the primitive array in this object.
- * @param data The DataBuffer containing the image data.
- */
- public abstract Object getPixelData(int x, int y,
- Object obj, DataBuffer data);
-
- /**
- * Returns the pixel data for the specified rectangle 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.
- * <pre>
- * SampleModel sm1, sm2;
- * DataBuffer db1, db2;
- * sm2.setPixelData(x, y, w, h, sm1.getPixelData(x, y, w,
- * h, null, db1), db2);
- * </pre>
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param w The width of the pixel rectangle.
- * @param h The height of the pixel rectangle.
- * @param obj If non-null, returns the primitive array in this object.
- * @param data The DataBuffer containing the image data.
- */
- public Object getPixelData(int x, int y, int w, int h,
- Object obj, DataBuffer data) {
-
- int type = getTransferType();
- int numDataElems = getNumDataElements();
- int cnt = 0;
- Object o = null;
-
- switch(type) {
-
- case DataBuffer.BYTE_DATA:
-
- byte[] btemp;
- byte[] bdata;
-
- if (obj == null)
- bdata = new byte[numDataElems*w*h];
- else
- bdata = (byte[])obj;
-
- for (int i=y; i<y+h; i++) {
- for (int j=x; j<x+w; j++) {
- o = getPixelData(j, i, o, data);
- btemp = (byte[])o;
- for (int k=0; k<numDataElems; k++) {
- bdata[cnt++] = btemp[k];
- }
- }
- }
- obj = (Object)bdata;
- break;
-
- case DataBuffer.SHORT_DATA:
-
- short[] sdata;
- short[] stemp;
-
- if (obj == null)
- sdata = new short[numDataElems*w*h];
- else
- sdata = (short[])obj;
-
- for (int i=y; i<y+h; i++) {
- for (int j=x; j<x+w; j++) {
- o = getPixelData(j, i, o, data);
- stemp = (short[])o;
- for (int k=0; k<numDataElems; k++) {
- sdata[cnt++] = stemp[k];
- }
- }
- }
-
- obj = (Object)sdata;
- break;
-
- case DataBuffer.INT_DATA:
-
- int[] idata;
- int[] itemp;
-
- if (obj == null)
- idata = new int[numDataElems*w*h];
- else
- idata = (int[])obj;
-
- for (int i=y; i<y+h; i++) {
- for (int j=x; j<x+w; j++) {
- o = getPixelData(j, i, o, data);
- itemp = (int[])o;
- for (int k=0; k<numDataElems; k++) {
- idata[cnt++] = itemp[k];
- }
- }
- }
-
- obj = (Object)idata;
- break;
- }
-
- return obj;
- }
-
- /**
- * 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.
- * <pre>
- * SampleModel sm1, sm2;
- * DataBuffer db1, db2;
- * sm2.setPixelData(x, y, sm1.getPixelData(x, y, null, db1), db2);
- * </pre>
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param obj If non-null, returns the primitive array in this object.
- * @param data The DataBuffer containing the image data.
- */
- public abstract void setPixelData(int x, int y,
- Object obj, DataBuffer data);
-
- /**
- * Puts the rectangle of 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.
- * <pre>
- * SampleModel sm1, sm2;
- * DataBuffer db1, db2;
- * sm2.setPixelData(x, y, w, h, sm1.getPixelData(x, y, w, h, null,
- * db1), db2);
- * </pre>
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param w The width of the pixel rectangle.
- * @param h The height of the pixel rectangle.
- * @param obj If non-null, returns the primitive array in this object.
- * @param data The DataBuffer containing the image data.
- */
- void setPixelData(int x, int y, int w, int h, Object obj, DataBuffer data) {
-
- int cnt = 0;
- Object o = null;
- int type = getTransferType();
- int numDataElems = getNumDataElements();
-
- switch(type) {
-
- case DataBuffer.BYTE_DATA:
-
- byte[] barray = (byte[])obj;
- byte[] btemp = new byte[numDataElems];
-
- for (int i=y; i<y+h; i++) {
- for (int j=x; j<x+w; j++) {
- for (int k=0; k<numDataElems; k++) {
- btemp[k] = barray[cnt++];
- }
-
- setPixelData(j, i, btemp, data);
- }
- }
- break;
-
- case DataBuffer.SHORT_DATA:
-
- short[] sarray = (short[])obj;
- short[] stemp = new short[numDataElems];
-
- for (int i=y; i<y+h; i++) {
- for (int j=x; j<x+w; j++) {
- for (int k=0; k<numDataElems; k++) {
- stemp[k] = sarray[cnt++];
- }
-
- setPixelData(j, i, stemp, data);
- }
- }
- break;
-
- case DataBuffer.INT_DATA:
-
- int[] iarray = (int[])obj;
- int[] itemp = new int[numDataElems];
-
- for (int i=y; i<y+h; i++) {
- for (int j=x; j<x+w; j++) {
- for (int k=0; k<numDataElems; k++) {
- itemp[k] = iarray[cnt++];
- }
-
- setPixelData(j, i, itemp, data);
- }
- }
- break;
- }
-
- }
-
- /**
- * Returns the samples for the specified pixel in an array of float.
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param fArray If non-null, returns the samples in this array.
- * @param data The DataBuffer containing the image data.
- */
- public float[] getPixel(int x, int y, float fArray[],
- DataBuffer data) {
-
- float pixels[];
-
- if (fArray != null)
- pixels = fArray;
- else
- pixels = new float[numBands];
-
- for (int i=0; i<numBands; i++)
- pixels[i] = getSampleFloat(x, y, i, data);
-
- return pixels;
- }
-
- /**
- * Returns the samples for the specified pixle in an array of double.
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param dArray If non-null, returns the samples in this array.
- * @param data The DataBuffer containing the image data.
- */
- public double[] getPixel(int x, int y, double dArray[],
- DataBuffer data) {
-
- double pixels[];
-
- if(dArray != null)
- pixels = dArray;
- else
- pixels = new double[numBands];
-
- for (int i=0; i<numBands; i++)
- pixels[i] = getSampleDouble(x, y, i, data);
-
- return pixels;
- }
-
- /**
- * Returns all samples for a rectangle of pixels in an
- * int array, one sample per array element.
- * @param x The X coordinate of the upper left pixel location.
- * @param y The Y coordinate of the upper left pixel location.
- * @param w The width of the pixel rectangle.
- * @param h The height of the pixel rectangle.
- * @param iArray If non-null, returns the samples in this array.
- * @param data The DataBuffer containing the image data.
- */
- public int[] getPixel(int x, int y, int w, int h,
- int iArray[], DataBuffer data) {
-
- int pixels[];
- int Offset=0;
-
- if (iArray != null)
- pixels = iArray;
- else
- pixels = new int[numBands * w * h];
-
- for (int i=y; i<(h+y); i++) {
- for (int j=x; j<(w+x); j++) {
- for(int k=0; k<numBands; k++) {
- pixels[Offset++] = getSample(j, i, k, data);
- }
- }
- }
-
- return pixels;
- }
-
- /**
- * Returns all samples for a rectangle of pixels in a float
- * array, one sample per array element.
- * @param x The X coordinate of the upper left pixel location.
- * @param y The Y coordinate of the upper left pixel location.
- * @param w The width of the pixel rectangle.
- * @param h The height of the pixel rectangle.
- * @param fArray If non-null, returns the samples in this array.
- * @param data The DataBuffer containing the image data.
- */
- public float[] getPixel(int x, int y, int w, int h,
- float fArray[], DataBuffer data) {
-
- float pixels[];
- int Offset = 0;
-
- if (fArray != null)
- pixels = fArray;
- else
- pixels = new float[numBands * w * h];
-
- for (int i=y; i<(h+y); i++) {
- for(int j=x; j<(w+x); j++) {
- for(int k=0; k<numBands; k++) {
- pixels[Offset++] = getSampleFloat(j, i, k, data);
- }
- }
- }
-
- return pixels;
- }
-
- /**
- * Returns all samples for a rectangle of pixels in a double
- * array, one sample per array element.
- * @param x The X coordinate of the upper left pixel location.
- * @param y The Y coordinate of the upper left pixel location.
- * @param w The width of the pixel rectangle.
- * @param h The height of the pixel rectangle.
- * @param dArray If non-null, returns the samples in this array.
- * @param data The DataBuffer containing the image data.
- */
- public double[] getPixel(int x, int y, int w, int h,
- double dArray[], DataBuffer data) {
- double pixels[];
- int Offset = 0;
-
- if (dArray != null)
- pixels = dArray;
- else
- pixels = new double[numBands * w * h];
-
- for (int i=0; i<(h+y); i++) {
- for (int j=0; j<(w+x); j++) {
- for (int k=0; k<numBands; k++) {
- pixels[Offset++] = getSampleDouble(j, i, k, data);
- }
- }
- }
-
- return pixels;
- }
-
-
- /**
- * Returns the sample in a specified band for the pixel located
- * at (x,y) as an int.
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param b The band to return.
- * @param data The DataBuffer containing the image data.
- */
- 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 a float.
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param b The band to return.
- * @param data The DataBuffer containing the image data.
- */
- public float getSampleFloat(int x, int y, int b, DataBuffer data) {
-
- float sample;
- sample = (float) getSample(x, y, b, data);
- return sample;
- }
-
- /**
- * Returns the sample in a specified band
- * for a pixel located at (x,y) as a double.
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param b The band to return.
- * @param data The DataBuffer containing the image data.
- */
- public double getSampleDouble(int x, int y, int b, DataBuffer data) {
-
- double sample;
-
- sample = (double) getSample(x, y, b, data);
- return sample;
- }
-
- /**
- * Returns the samples for a specified band for the specified rectangle
- * of pixels in an int array, one sample per array element.
- * @param x The X coordinate of the upper left pixel location.
- * @param y The Y coordinate of the upper left pixel location.
- * @param w The width of the pixel rectangle.
- * @param h The height of the pixel rectangle.
- * @param b The band to return.
- * @param iArray If non-null, returns the samples in this array.
- * @param data The DataBuffer containing the image data.
- */
- public int[] getSample(int x, int y, int w, int h, int b,
- int iArray[], DataBuffer data) {
- int pixels[];
- int Offset=0;
-
- if (iArray != null)
- pixels = iArray;
- else
- pixels = new int[w * h];
-
- for(int i=y; i<(h+y); i++) {
- for (int j=x; j<(w+x); j++) {
- pixels[Offset++] = getSample(j, i, b, data);
- }
- }
-
- return pixels;
- }
-
- /**
- * Returns the samples for a specified band for the specified rectangle
- * of pixels in a float array, one sample per array element.
- * @param x The X coordinate of the upper left pixel location.
- * @param y The Y coordinate of the upper left pixel location.
- * @param w The width of the pixel rectangle.
- * @param h The height of the pixel rectangle.
- * @param b The band to return.
- * @param fArray If non-null, returns the samples in this array.
- * @param data The DataBuffer containing the image data.
- */
- public float[] getSample(int x, int y, int w, int h,
- int b, float fArray[],
- DataBuffer data) {
- float pixels[];
- int Offset=0;
-
- if (fArray != null)
- pixels = fArray;
- else
- pixels = new float[w * h];
-
- for (int i=y; i<(h+y); i++) {
- for (int j=x; j<(w+x); j++) {
- pixels[Offset++] = getSampleFloat(j, i, b, data);
- }
- }
-
- return pixels;
- }
-
- /**
- * Returns the samples for a specified band for a specified rectangle
- * of pixels in a double array, one sample per array element.
- * @param x The X coordinate of the upper left pixel location.
- * @param y The Y coordinate of the upper left pixel location.
- * @param w The width of the pixel rectangle.
- * @param h The height of the pixel rectangle.
- * @param b The band to return.
- * @param dArray If non-null, returns the samples in this array.
- * @param data The DataBuffer containing the image data.
- */
- public double[] getSample(int x, int y, int w, int h,
- int b, double dArray[],
- DataBuffer data) {
- double pixels[];
- int Offset=0;
-
- if (dArray != null)
- pixels = dArray;
- else
- pixels = new double[w * h];
-
- for (int i=y; i<(y+h); i++) {
- for (int j=x; j<(x+w); j++) {
- pixels[Offset++] = getSampleDouble(j, i, b, data);
- }
- }
-
- return pixels;
- }
-
- /**
- * Sets a pixel in the DataBuffer using an int array of samples for input.
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param iArray The input samples in an int array.
- * @param data The DataBuffer containing the image data.
- */
- public void setPixel(int x, int y, int iArray[], DataBuffer data) {
-
- for (int i=0; i<numBands; i++)
- setSample(x, y, i, iArray[i], data);
- }
-
- /**
- * Sets a pixel in the DataBuffer using a float array of samples for input.
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param fArray The input samples in a float array.
- * @param data The DataBuffer containing the image data.
- */
- public void setPixel(int x, int y, float fArray[], DataBuffer data) {
-
- for (int i=0; i<numBands; i++)
- setSample(x, y, i, fArray[i], data);
- }
-
- /**
- * Sets a pixel in the DataBuffer using a double array of samples for input.
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param dArray The input samples in a double array.
- * @param data The DataBuffer containing the image data.
- */
- public void setPixel(int x, int y, double dArray[], DataBuffer data) {
-
- for (int i=0; i<numBands; i++)
- setSample(x, y, i, dArray[i], data);
- }
-
- /**
- * Sets all samples for a rectangle of pixels from an int array containing
- * one sample per array element.
- * @param x The X coordinate of the upper left pixel location.
- * @param y The Y coordinate of the upper left pixel location.
- * @param w The width of the pixel rectangle.
- * @param h The height of the pixel rectangle.
- * @param iArray The input samples in an int array.
- * @param data The DataBuffer containing the image data.
- */
- public void setPixel(int x, int y, int w, int h,
- int iArray[], DataBuffer data) {
- int Offset=0;
-
- for (int i=y; i<(y+h); i++) {
- for (int j=x; j<(x+w); j++) {
- for (int k=0; k<numBands; k++) {
- setSample(j, i, k, iArray[Offset++], data);
- }
- }
- }
- }
-
- /**
- * Sets all samples for a rectangle of pixels from a float array containing
- * one sample per array element.
- * @param x The X coordinate of the upper left pixel location.
- * @param y The Y coordinate of the upper left pixel location.
- * @param w The width of the pixel rectangle.
- * @param h The height of the pixel rectangle.
- * @param fArray The input samples in a float array.
- * @param data The DataBuffer containing the image data.
- */
- public void setPixel(int x, int y, int w, int h,
- float fArray[], DataBuffer data) {
- int Offset=0;
-
- for (int i=y; i<(y+h); i++) {
- for (int j=x; j<(x+w); j++) {
- for(int k=0; k<numBands; k++) {
- setSample(j, i, k, fArray[Offset++], data);
- }
- }
- }
- }
-
- /**
- * Sets all samples for a rectangle of pixels from a double array containing
- * one sample per array element.
- * @param x The X coordinate of the upper left pixel location.
- * @param y The Y coordinate of the upper left pixel location.
- * @param w The width of the pixel rectangle.
- * @param h The height of the pixel rectangle.
- * @param dArray The input samples in a double array.
- * @param data The DataBuffer containing the image data.
- */
- public void setPixel(int x, int y, int w, int h,
- double dArray[], DataBuffer data) {
- int Offset=0;
-
- for (int i=y; i<(y+h); i++) {
- for (int j=x; j<(x+w); j++) {
- for (int k=0; k<numBands; k++) {
- setSample(j, i, k, dArray[k], data);
- }
- }
- }
- }
-
- /**
- * Sets a sample in the specified band for the pixel located at (x,y)
- * in the DataBuffer using an int for input.
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param b The band to set.
- * @param s The input sample as an int.
- * @param data The DataBuffer containing the image data.
- */
- 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 a float for input.
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param b The band to set.
- * @param s The input sample as a float.
- * @param data The DataBuffer containing the image data.
- */
- public void setSample(int x, int y, int b,
- float s ,
- DataBuffer data) {
- int sample = (int)s;
-
- setSample(x, y, b, sample, data);
- }
-
- /**
- * Sets a sample in the specified band for the pixel located at (x,y)
- * in the DataBuffer using a double for input.
- * @param x The X coordinate of the pixel location.
- * @param y The Y coordinate of the pixel location.
- * @param b The band to set.
- * @param s The input sample as a double.
- * @param data The DataBuffer containing the image data.
- */
- public void setSample(int x, int y, int b,
- double s,
- DataBuffer data) {
- int sample = (int)s;
-
- setSample(x, y, b, sample, data);
- }
-
- /**
- * Sets the samples in the specified band for the specified rectangle
- * of pixels from an int array containing one sample per array element.
- * @param x The X coordinate of the upper left pixel location.
- * @param y The Y coordinate of the upper left pixel location.
- * @param w The width of the pixel rectangle.
- * @param h The height of the pixel rectangle.
- * @param b The band to set.
- * @param iArray The input samples in an int array.
- * @param data The DataBuffer containing the image data.
- */
- public void setSample(int x, int y, int w, int h, int b,
- int iArray[], DataBuffer data) {
-
- int Offset=0;
-
- for (int i=y; i<(y+h); i++) {
- for (int j=x; j<(x+w); j++) {
- setSample(j, i, b, iArray[Offset++], data);
- }
- }
- }
-
- /**
- * Sets the samples in the specified band for the specified rectangle
- * of pixels from a float array containing one sample per array element.
- * @param x The X coordinate of the upper left pixel location.
- * @param y The Y coordinate of the upper left pixel location.
- * @param w The width of the pixel rectangle.
- * @param h The height of the pixel rectangle.
- * @param b The band to set.
- * @param fArray The input samples in a float array.
- * @param data The DataBuffer containing the image data.
- */
- public void setSample(int x, int y, int w, int h, int b,
- float fArray[], DataBuffer data) {
- int Offset=0;
-
- for (int i=y; i<(y+h); i++) {
- for (int j=x; j<(x+w); j++) {
- setSample(j, i, b, fArray[Offset++], data);
- }
- }
- }
-
- /**
- * Sets the samples in the specified band for the specified rectangle
- * of pixels from a double array containing one sample per array element.
- * @param x The X coordinate of the upper left pixel location.
- * @param y The Y coordinate of the upper left pixel location.
- * @param w The width of the pixel rectangle.
- * @param h The height of the pixel rectangle.
- * @param b The band to set.
- * @param dArray The input samples in a double array.
- * @param data The DataBuffer containing the image data.
- */
- public void setSample(int x, int y, int w, int h, int b,
- double dArray[], DataBuffer data) {
- int Offset=0;
-
- for (int i=y; i<(y+h); i++) {
- for (int j=x; j<(x+w); j++) {
- setSample(j, i, b, dArray[Offset++], data);
- }
- }
- }
-
- /**
- * Creates a SampleModel which describes data in this SampleModel's
- * format, but with a different width and height.
- */
- public abstract SampleModel createCompatibleSampleModel(int w, int h);
-
- /**
- * This creates a new SampleModel with the requested
- * width and height and with a subset of the bands of this
- * SampleModel.
- */
- public abstract SampleModel createSubsetSampleModel(int w,
- int h, int bands[]);
-
- /**
- * Creates a DataBuffer that corresponds to this SampleModel.
- * The DataBuffer's width and height will match this SampleModel's.
- */
- public abstract DataBuffer createCompatibleDataBuffer();
-
- /**
- * Creates a DataBuffer that corresponds to this SampleModel,
- * with a different width and height.
- */
- public abstract DataBuffer
- createCompatibleDataBuffer(int width, int height);
-
- /** Returns the minimum sample value for all bands. */
- public float getMinSampleValue() {
- return minMinSampleValue;
- }
-
- /** Returns the minimum sample value for the specified band. */
- public float getMinSampleValue(int band) {
- return minSampleValue[band];
- }
-
- /** Returns the maximum sample value for all bands. */
- public float getMaxSampleValue() {
- return maxMaxSampleValue;
- }
-
- /** Returns the maximum sample value for the specified band. */
- public float getMaxSampleValue(int band) {
- return maxSampleValue[band];
- }
-
- /** Returns the size in bits of samples for all bands. */
- public abstract int[] getSampleSize();
-
- /** Returns the size in bits of samples for the specified band. */
- public abstract int getSampleSize(int band);
- }
-
-
-
-
-