290N/A/*
2362N/A * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
290N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
290N/A *
290N/A * This code is free software; you can redistribute it and/or modify it
290N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
290N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
290N/A *
290N/A * This code is distributed in the hope that it will be useful, but WITHOUT
290N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
290N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
290N/A * version 2 for more details (a copy is included in the LICENSE file that
290N/A * accompanied this code).
290N/A *
290N/A * You should have received a copy of the GNU General Public License version
290N/A * 2 along with this work; if not, write to the Free Software Foundation,
290N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
290N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
290N/A */
290N/A
290N/A/* ****************************************************************
290N/A ******************************************************************
290N/A ******************************************************************
290N/A *** COPYRIGHT (c) Eastman Kodak Company, 1997
290N/A *** As an unpublished work pursuant to Title 17 of the United
290N/A *** States Code. All rights reserved.
290N/A ******************************************************************
290N/A ******************************************************************
290N/A ******************************************************************/
290N/A
290N/Apackage java.awt.image;
290N/Aimport java.awt.Rectangle;
290N/Aimport java.awt.Point;
290N/A
290N/A/**
290N/A * This class extends Raster to provide pixel writing capabilities.
290N/A * Refer to the class comment for Raster for descriptions of how
290N/A * a Raster stores pixels.
290N/A *
290N/A * <p> The constructors of this class are protected. To instantiate
290N/A * a WritableRaster, use one of the createWritableRaster factory methods
290N/A * in the Raster class.
290N/A */
290N/Apublic class WritableRaster extends Raster {
290N/A
290N/A /**
290N/A * Constructs a WritableRaster with the given SampleModel. The
290N/A * WritableRaster's upper left corner is origin and it is the
290N/A * same size as the SampleModel. A DataBuffer large enough to
290N/A * describe the WritableRaster is automatically created.
290N/A * @param sampleModel The SampleModel that specifies the layout.
290N/A * @param origin The Point that specifies the origin.
290N/A * @throws RasterFormatException if computing either
290N/A * <code>origin.x + sampleModel.getWidth()</code> or
290N/A * <code>origin.y + sampleModel.getHeight()</code> results
290N/A * in integer overflow
290N/A */
290N/A protected WritableRaster(SampleModel sampleModel,
290N/A Point origin) {
290N/A this(sampleModel,
290N/A sampleModel.createDataBuffer(),
290N/A new Rectangle(origin.x,
290N/A origin.y,
290N/A sampleModel.getWidth(),
290N/A sampleModel.getHeight()),
290N/A origin,
290N/A null);
290N/A }
290N/A
290N/A /**
290N/A * Constructs a WritableRaster with the given SampleModel and DataBuffer.
290N/A * The WritableRaster's upper left corner is origin and it is the same
290N/A * size as the SampleModel. The DataBuffer is not initialized and must
290N/A * be compatible with SampleModel.
290N/A * @param sampleModel The SampleModel that specifies the layout.
290N/A * @param dataBuffer The DataBuffer that contains the image data.
290N/A * @param origin The Point that specifies the origin.
290N/A * @throws RasterFormatException if computing either
290N/A * <code>origin.x + sampleModel.getWidth()</code> or
290N/A * <code>origin.y + sampleModel.getHeight()</code> results
290N/A * in integer overflow
290N/A */
290N/A protected WritableRaster(SampleModel sampleModel,
290N/A DataBuffer dataBuffer,
290N/A Point origin) {
290N/A this(sampleModel,
290N/A dataBuffer,
290N/A new Rectangle(origin.x,
290N/A origin.y,
290N/A sampleModel.getWidth(),
290N/A sampleModel.getHeight()),
290N/A origin,
290N/A null);
290N/A }
290N/A
290N/A /**
290N/A * Constructs a WritableRaster with the given SampleModel, DataBuffer,
290N/A * and parent. aRegion specifies the bounding rectangle of the new
290N/A * Raster. When translated into the base Raster's coordinate
290N/A * system, aRegion must be contained by the base Raster.
290N/A * (The base Raster is the Raster's ancestor which has no parent.)
290N/A * sampleModelTranslate specifies the sampleModelTranslateX and
290N/A * sampleModelTranslateY values of the new Raster.
290N/A *
290N/A * Note that this constructor should generally be called by other
290N/A * constructors or create methods, it should not be used directly.
290N/A * @param sampleModel The SampleModel that specifies the layout.
290N/A * @param dataBuffer The DataBuffer that contains the image data.
290N/A * @param aRegion The Rectangle that specifies the image area.
290N/A * @param sampleModelTranslate The Point that specifies the translation
290N/A * from SampleModel to Raster coordinates.
290N/A * @param parent The parent (if any) of this raster.
290N/A * @throws RasterFormatException if <code>aRegion</code> has width
290N/A * or height less than or equal to zero, or computing either
290N/A * <code>aRegion.x + aRegion.width</code> or
290N/A * <code>aRegion.y + aRegion.height</code> results in integer
290N/A * overflow
290N/A */
290N/A protected WritableRaster(SampleModel sampleModel,
290N/A DataBuffer dataBuffer,
290N/A Rectangle aRegion,
290N/A Point sampleModelTranslate,
290N/A WritableRaster parent){
290N/A super(sampleModel,dataBuffer,aRegion,sampleModelTranslate,parent);
290N/A }
290N/A
290N/A /** Returns the parent WritableRaster (if any) of this WritableRaster,
290N/A * or else null.
290N/A * @return the parent of this <code>WritableRaster</code>, or
290N/A * <code>null</code>.
290N/A */
290N/A public WritableRaster getWritableParent() {
290N/A return (WritableRaster)parent;
290N/A }
290N/A
290N/A /**
290N/A * Create a WritableRaster with the same size, SampleModel and DataBuffer
290N/A * as this one, but with a different location. The new WritableRaster
290N/A * will possess a reference to the current WritableRaster, accessible
290N/A * through its getParent() and getWritableParent() methods.
290N/A *
290N/A * @param childMinX X coord of the upper left corner of the new Raster.
290N/A * @param childMinY Y coord of the upper left corner of the new Raster.
290N/A * @return a <code>WritableRaster</code> the same as this one except
290N/A * for the specified location.
290N/A * @throws RasterFormatException if computing either
290N/A * <code>childMinX + this.getWidth()</code> or
290N/A * <code>childMinY + this.getHeight()</code> results in integer
290N/A * overflow
290N/A */
290N/A public WritableRaster createWritableTranslatedChild(int childMinX,
290N/A int childMinY) {
290N/A return createWritableChild(minX,minY,width,height,
290N/A childMinX,childMinY,null);
290N/A }
290N/A
290N/A /**
290N/A * Returns a new WritableRaster which shares all or part of this
290N/A * WritableRaster's DataBuffer. The new WritableRaster will
290N/A * possess a reference to the current WritableRaster, accessible
290N/A * through its getParent() and getWritableParent() methods.
290N/A *
290N/A * <p> The parentX, parentY, width and height parameters form a
290N/A * Rectangle in this WritableRaster's coordinate space, indicating
290N/A * the area of pixels to be shared. An error will be thrown if
290N/A * this Rectangle is not contained with the bounds of the current
290N/A * WritableRaster.
290N/A *
290N/A * <p> The new WritableRaster may additionally be translated to a
290N/A * different coordinate system for the plane than that used by the current
290N/A * WritableRaster. The childMinX and childMinY parameters give
290N/A * the new (x, y) coordinate of the upper-left pixel of the
290N/A * returned WritableRaster; the coordinate (childMinX, childMinY)
290N/A * in the new WritableRaster will map to the same pixel as the
290N/A * coordinate (parentX, parentY) in the current WritableRaster.
290N/A *
290N/A * <p> The new WritableRaster may be defined to contain only a
290N/A * subset of the bands of the current WritableRaster, possibly
290N/A * reordered, by means of the bandList parameter. If bandList is
290N/A * null, it is taken to include all of the bands of the current
290N/A * WritableRaster in their current order.
290N/A *
290N/A * <p> To create a new WritableRaster that contains a subregion of
290N/A * the current WritableRaster, but shares its coordinate system
290N/A * and bands, this method should be called with childMinX equal to
290N/A * parentX, childMinY equal to parentY, and bandList equal to
290N/A * null.
290N/A *
290N/A * @param parentX X coordinate of the upper left corner in this
290N/A * WritableRaster's coordinates.
290N/A * @param parentY Y coordinate of the upper left corner in this
290N/A * WritableRaster's coordinates.
290N/A * @param w Width of the region starting at (parentX, parentY).
290N/A * @param h Height of the region starting at (parentX, parentY).
290N/A * @param childMinX X coordinate of the upper left corner of
290N/A * the returned WritableRaster.
290N/A * @param childMinY Y coordinate of the upper left corner of
290N/A * the returned WritableRaster.
290N/A * @param bandList Array of band indices, or null to use all bands.
290N/A * @return a <code>WritableRaster</code> sharing all or part of the
290N/A * <code>DataBuffer</code> of this <code>WritableRaster</code>.
290N/A * @exception RasterFormatException if the subregion is outside of the
290N/A * raster bounds.
290N/A * @throws RasterFormatException if <code>w</code> or
290N/A * <code>h</code>
290N/A * is less than or equal to zero, or computing any of
290N/A * <code>parentX + w</code>, <code>parentY + h</code>,
290N/A * <code>childMinX + w</code>, or
290N/A * <code>childMinY + h</code> results in integer
290N/A * overflow
290N/A */
290N/A public WritableRaster createWritableChild(int parentX, int parentY,
290N/A int w, int h,
290N/A int childMinX, int childMinY,
290N/A int bandList[]) {
290N/A if (parentX < this.minX) {
290N/A throw new RasterFormatException("parentX lies outside raster");
290N/A }
290N/A if (parentY < this.minY) {
290N/A throw new RasterFormatException("parentY lies outside raster");
290N/A }
290N/A if ((parentX+w < parentX) || (parentX+w > this.width + this.minX)) {
290N/A throw new RasterFormatException("(parentX + width) is outside raster");
290N/A }
290N/A if ((parentY+h < parentY) || (parentY+h > this.height + this.minY)) {
290N/A throw new RasterFormatException("(parentY + height) is outside raster");
290N/A }
290N/A
290N/A SampleModel sm;
290N/A // Note: the SampleModel for the child Raster should have the same
290N/A // width and height as that for the parent, since it represents
290N/A // the physical layout of the pixel data. The child Raster's width
290N/A // and height represent a "virtual" view of the pixel data, so
290N/A // they may be different than those of the SampleModel.
290N/A if (bandList != null) {
290N/A sm = sampleModel.createSubsetSampleModel(bandList);
290N/A }
290N/A else {
290N/A sm = sampleModel;
290N/A }
290N/A
290N/A int deltaX = childMinX - parentX;
290N/A int deltaY = childMinY - parentY;
290N/A
290N/A return new WritableRaster(sm,
290N/A getDataBuffer(),
290N/A new Rectangle(childMinX,childMinY,
290N/A w, h),
290N/A new Point(sampleModelTranslateX+deltaX,
290N/A sampleModelTranslateY+deltaY),
290N/A this);
290N/A }
290N/A
290N/A /**
290N/A * Sets the data for a single pixel from a
290N/A * primitive array of type TransferType. For image data supported by
290N/A * the Java 2D(tm) API, this will be one of DataBuffer.TYPE_BYTE,
290N/A * DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT,
290N/A * DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE. Data in the array
290N/A * may be in a packed format, thus increasing efficiency for data
290N/A * transfers.
290N/A * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
290N/A * not in bounds, or if inData is not large enough to hold the pixel data.
290N/A * However, explicit bounds checking is not guaranteed.
290N/A * A ClassCastException will be thrown if the input object is not null
290N/A * and references anything other than an array of TransferType.
290N/A * @see java.awt.image.SampleModel#setDataElements(int, int, Object, DataBuffer)
290N/A * @param x The X coordinate of the pixel location.
290N/A * @param y The Y coordinate of the pixel location.
290N/A * @param inData An object reference to an array of type defined by
290N/A * getTransferType() and length getNumDataElements()
290N/A * containing the pixel data to place at x,y.
290N/A *
290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates are not
290N/A * in bounds, or if inData is too small to hold the input.
290N/A */
290N/A public void setDataElements(int x, int y, Object inData) {
290N/A sampleModel.setDataElements(x-sampleModelTranslateX,
290N/A y-sampleModelTranslateY,
290N/A inData, dataBuffer);
290N/A }
290N/A
290N/A /**
290N/A * Sets the data for a rectangle of pixels from an input Raster.
290N/A * The input Raster must be compatible with this WritableRaster
290N/A * in that they must have the same number of bands, corresponding bands
290N/A * must have the same number of bits per sample, the TransferTypes
290N/A * and NumDataElements must be the same, and the packing used by
290N/A * the getDataElements/setDataElements must be identical.
290N/A * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
290N/A * not in bounds.
290N/A * However, explicit bounds checking is not guaranteed.
290N/A * @param x The X coordinate of the pixel location.
290N/A * @param y The Y coordinate of the pixel location.
290N/A * @param inRaster Raster containing data to place at x,y.
290N/A *
290N/A * @throws NullPointerException if inRaster is null.
290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates are not
290N/A * in bounds.
290N/A */
290N/A public void setDataElements(int x, int y, Raster inRaster) {
290N/A int dstOffX = x+inRaster.getMinX();
290N/A int dstOffY = y+inRaster.getMinY();
290N/A int width = inRaster.getWidth();
290N/A int height = inRaster.getHeight();
290N/A if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
290N/A (dstOffX + width > this.minX + this.width) ||
290N/A (dstOffY + height > this.minY + this.height)) {
290N/A throw new ArrayIndexOutOfBoundsException
290N/A ("Coordinate out of bounds!");
290N/A }
290N/A
290N/A int srcOffX = inRaster.getMinX();
290N/A int srcOffY = inRaster.getMinY();
290N/A Object tdata = null;
290N/A
290N/A for (int startY=0; startY < height; startY++) {
290N/A tdata = inRaster.getDataElements(srcOffX, srcOffY+startY,
290N/A width, 1, tdata);
290N/A setDataElements(dstOffX, dstOffY+startY,
290N/A width, 1, tdata);
290N/A }
290N/A }
290N/A
290N/A /**
290N/A * Sets the data for a rectangle of pixels from a
290N/A * primitive array of type TransferType. For image data supported by
290N/A * the Java 2D API, this will be one of DataBuffer.TYPE_BYTE,
290N/A * DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT,
290N/A * DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE. Data in the array
290N/A * may be in a packed format, thus increasing efficiency for data
290N/A * transfers.
290N/A * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
290N/A * not in bounds, or if inData is not large enough to hold the pixel data.
290N/A * However, explicit bounds checking is not guaranteed.
290N/A * A ClassCastException will be thrown if the input object is not null
290N/A * and references anything other than an array of TransferType.
290N/A * @see java.awt.image.SampleModel#setDataElements(int, int, int, int, Object, DataBuffer)
290N/A * @param x The X coordinate of the upper left pixel location.
290N/A * @param y The Y coordinate of the upper left pixel location.
290N/A * @param w Width of the pixel rectangle.
290N/A * @param h Height of the pixel rectangle.
290N/A * @param inData An object reference to an array of type defined by
290N/A * getTransferType() and length w*h*getNumDataElements()
290N/A * containing the pixel data to place between x,y and
290N/A * x+w-1, y+h-1.
290N/A *
290N/A * @throws NullPointerException if inData is null.
290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates are not
290N/A * in bounds, or if inData is too small to hold the input.
290N/A */
290N/A public void setDataElements(int x, int y, int w, int h, Object inData) {
290N/A sampleModel.setDataElements(x-sampleModelTranslateX,
290N/A y-sampleModelTranslateY,
290N/A w,h,inData,dataBuffer);
290N/A }
290N/A
290N/A /**
290N/A * Copies pixels from Raster srcRaster to this WritableRaster. Each pixel
290N/A * in srcRaster is copied to the same x,y address in this raster, unless
290N/A * the address falls outside the bounds of this raster. srcRaster
290N/A * must have the same number of bands as this WritableRaster. The
290N/A * copy is a simple copy of source samples to the corresponding destination
290N/A * samples.
290N/A * <p>
290N/A * If all samples of both source and destination Rasters are of
290N/A * integral type and less than or equal to 32 bits in size, then calling
290N/A * this method is equivalent to executing the following code for all
290N/A * <code>x,y</code> addresses valid in both Rasters.
290N/A * <pre>
290N/A * Raster srcRaster;
290N/A * WritableRaster dstRaster;
290N/A * for (int b = 0; b < srcRaster.getNumBands(); b++) {
290N/A * dstRaster.setSample(x, y, b, srcRaster.getSample(x, y, b));
290N/A * }
290N/A * </pre>
290N/A * Thus, when copying an integral type source to an integral type
290N/A * destination, if the source sample size is greater than the destination
290N/A * sample size for a particular band, the high order bits of the source
290N/A * sample are truncated. If the source sample size is less than the
290N/A * destination size for a particular band, the high order bits of the
290N/A * destination are zero-extended or sign-extended depending on whether
290N/A * srcRaster's SampleModel treats the sample as a signed or unsigned
290N/A * quantity.
290N/A * <p>
290N/A * When copying a float or double source to an integral type destination,
290N/A * each source sample is cast to the destination type. When copying an
290N/A * integral type source to a float or double destination, the source
290N/A * is first converted to a 32-bit int (if necessary), using the above
290N/A * rules for integral types, and then the int is cast to float or
290N/A * double.
290N/A * <p>
290N/A * @param srcRaster The Raster from which to copy pixels.
290N/A *
290N/A * @throws NullPointerException if srcRaster is null.
290N/A */
290N/A public void setRect(Raster srcRaster) {
290N/A setRect(0,0,srcRaster);
290N/A }
290N/A
290N/A /**
290N/A * Copies pixels from Raster srcRaster to this WritableRaster.
290N/A * For each (x, y) address in srcRaster, the corresponding pixel
290N/A * is copied to address (x+dx, y+dy) in this WritableRaster,
290N/A * unless (x+dx, y+dy) falls outside the bounds of this raster.
290N/A * srcRaster must have the same number of bands as this WritableRaster.
290N/A * The copy is a simple copy of source samples to the corresponding
290N/A * destination samples. For details, see
290N/A * {@link WritableRaster#setRect(Raster)}.
290N/A *
290N/A * @param dx The X translation factor from src space to dst space
290N/A * of the copy.
290N/A * @param dy The Y translation factor from src space to dst space
290N/A * of the copy.
290N/A * @param srcRaster The Raster from which to copy pixels.
290N/A *
290N/A * @throws NullPointerException if srcRaster is null.
290N/A */
290N/A public void setRect(int dx, int dy, Raster srcRaster) {
290N/A int width = srcRaster.getWidth();
290N/A int height = srcRaster.getHeight();
290N/A int srcOffX = srcRaster.getMinX();
290N/A int srcOffY = srcRaster.getMinY();
290N/A int dstOffX = dx+srcOffX;
290N/A int dstOffY = dy+srcOffY;
290N/A
290N/A // Clip to this raster
290N/A if (dstOffX < this.minX) {
290N/A int skipX = this.minX - dstOffX;
290N/A width -= skipX;
290N/A srcOffX += skipX;
290N/A dstOffX = this.minX;
290N/A }
290N/A if (dstOffY < this.minY) {
290N/A int skipY = this.minY - dstOffY;
290N/A height -= skipY;
290N/A srcOffY += skipY;
290N/A dstOffY = this.minY;
290N/A }
290N/A if (dstOffX+width > this.minX+this.width) {
290N/A width = this.minX + this.width - dstOffX;
290N/A }
290N/A if (dstOffY+height > this.minY+this.height) {
290N/A height = this.minY + this.height - dstOffY;
290N/A }
290N/A
290N/A if (width <= 0 || height <= 0) {
290N/A return;
290N/A }
290N/A
290N/A switch (srcRaster.getSampleModel().getDataType()) {
290N/A case DataBuffer.TYPE_BYTE:
290N/A case DataBuffer.TYPE_SHORT:
290N/A case DataBuffer.TYPE_USHORT:
290N/A case DataBuffer.TYPE_INT:
290N/A int[] iData = null;
290N/A for (int startY=0; startY < height; startY++) {
290N/A // Grab one scanline at a time
290N/A iData =
290N/A srcRaster.getPixels(srcOffX, srcOffY+startY, width, 1,
290N/A iData);
290N/A setPixels(dstOffX, dstOffY+startY, width, 1, iData);
290N/A }
290N/A break;
290N/A
290N/A case DataBuffer.TYPE_FLOAT:
290N/A float[] fData = null;
290N/A for (int startY=0; startY < height; startY++) {
290N/A fData =
290N/A srcRaster.getPixels(srcOffX, srcOffY+startY, width, 1,
290N/A fData);
290N/A setPixels(dstOffX, dstOffY+startY, width, 1, fData);
290N/A }
290N/A break;
290N/A
290N/A case DataBuffer.TYPE_DOUBLE:
290N/A double[] dData = null;
290N/A for (int startY=0; startY < height; startY++) {
290N/A // Grab one scanline at a time
290N/A dData =
290N/A srcRaster.getPixels(srcOffX, srcOffY+startY, width, 1,
290N/A dData);
290N/A setPixels(dstOffX, dstOffY+startY, width, 1, dData);
290N/A }
290N/A break;
290N/A }
290N/A }
290N/A
290N/A /**
290N/A * Sets a pixel in the DataBuffer using an int array of samples for input.
290N/A * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
290N/A * not in bounds.
290N/A * However, explicit bounds checking is not guaranteed.
290N/A * @param x The X coordinate of the pixel location.
290N/A * @param y The Y coordinate of the pixel location.
290N/A * @param iArray The input samples in a int array.
290N/A *
290N/A * @throws NullPointerException if iArray is null.
290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates are not
290N/A * in bounds, or if iArray is too small to hold the input.
290N/A */
290N/A public void setPixel(int x, int y, int iArray[]) {
290N/A sampleModel.setPixel(x-sampleModelTranslateX,y-sampleModelTranslateY,
290N/A iArray,dataBuffer);
290N/A }
290N/A
290N/A /**
290N/A * Sets a pixel in the DataBuffer using a float array of samples for input.
290N/A * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
290N/A * not in bounds.
290N/A * However, explicit bounds checking is not guaranteed.
290N/A * @param x The X coordinate of the pixel location.
290N/A * @param y The Y coordinate of the pixel location.
290N/A * @param fArray The input samples in a float array.
290N/A *
290N/A * @throws NullPointerException if fArray is null.
290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates are not
290N/A * in bounds, or if fArray is too small to hold the input.
290N/A */
290N/A public void setPixel(int x, int y, float fArray[]) {
290N/A sampleModel.setPixel(x-sampleModelTranslateX,y-sampleModelTranslateY,
290N/A fArray,dataBuffer);
290N/A }
290N/A
290N/A /**
290N/A * Sets a pixel in the DataBuffer using a double array of samples for input.
290N/A * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
290N/A * not in bounds.
290N/A * However, explicit bounds checking is not guaranteed.
290N/A * @param x The X coordinate of the pixel location.
290N/A * @param y The Y coordinate of the pixel location.
290N/A * @param dArray The input samples in a double array.
290N/A *
290N/A * @throws NullPointerException if dArray is null.
290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates are not
290N/A * in bounds, or if dArray is too small to hold the input.
290N/A */
290N/A public void setPixel(int x, int y, double dArray[]) {
290N/A sampleModel.setPixel(x-sampleModelTranslateX,y-sampleModelTranslateY,
290N/A dArray,dataBuffer);
290N/A }
290N/A
290N/A /**
290N/A * Sets all samples for a rectangle of pixels from an int array containing
290N/A * one sample per array element.
290N/A * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
290N/A * not in bounds.
290N/A * However, explicit bounds checking is not guaranteed.
290N/A * @param x The X coordinate of the upper left pixel location.
290N/A * @param y The Y coordinate of the upper left pixel location.
290N/A * @param w Width of the pixel rectangle.
290N/A * @param h Height of the pixel rectangle.
290N/A * @param iArray The input int pixel array.
290N/A *
290N/A * @throws NullPointerException if iArray is null.
290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates are not
290N/A * in bounds, or if iArray is too small to hold the input.
290N/A */
290N/A public void setPixels(int x, int y, int w, int h, int iArray[]) {
290N/A sampleModel.setPixels(x-sampleModelTranslateX,y-sampleModelTranslateY,
290N/A w,h,iArray,dataBuffer);
290N/A }
290N/A
290N/A /**
290N/A * Sets all samples for a rectangle of pixels from a float array containing
290N/A * one sample per array element.
290N/A * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
290N/A * not in bounds.
290N/A * However, explicit bounds checking is not guaranteed.
290N/A * @param x The X coordinate of the upper left pixel location.
290N/A * @param y The Y coordinate of the upper left pixel location.
290N/A * @param w Width of the pixel rectangle.
290N/A * @param h Height of the pixel rectangle.
290N/A * @param fArray The input float pixel array.
290N/A *
290N/A * @throws NullPointerException if fArray is null.
290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates are not
290N/A * in bounds, or if fArray is too small to hold the input.
290N/A */
290N/A public void setPixels(int x, int y, int w, int h, float fArray[]) {
290N/A sampleModel.setPixels(x-sampleModelTranslateX,y-sampleModelTranslateY,
290N/A w,h,fArray,dataBuffer);
290N/A }
290N/A
290N/A /**
290N/A * Sets all samples for a rectangle of pixels from a double array containing
290N/A * one sample per array element.
290N/A * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
290N/A * not in bounds.
290N/A * However, explicit bounds checking is not guaranteed.
290N/A * @param x The X coordinate of the upper left pixel location.
290N/A * @param y The Y coordinate of the upper left pixel location.
290N/A * @param w Width of the pixel rectangle.
290N/A * @param h Height of the pixel rectangle.
290N/A * @param dArray The input double pixel array.
290N/A *
290N/A * @throws NullPointerException if dArray is null.
290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates are not
290N/A * in bounds, or if dArray is too small to hold the input.
290N/A */
290N/A public void setPixels(int x, int y, int w, int h, double dArray[]) {
290N/A sampleModel.setPixels(x-sampleModelTranslateX,y-sampleModelTranslateY,
290N/A w,h,dArray,dataBuffer);
290N/A }
290N/A
290N/A /**
290N/A * Sets a sample in the specified band for the pixel located at (x,y)
290N/A * in the DataBuffer using an int for input.
290N/A * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
290N/A * not in bounds.
290N/A * However, explicit bounds checking is not guaranteed.
290N/A * @param x The X coordinate of the pixel location.
290N/A * @param y The Y coordinate of the pixel location.
290N/A * @param b The band to set.
290N/A * @param s The input sample.
290N/A *
290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates or
290N/A * the band index are not in bounds.
290N/A */
290N/A public void setSample(int x, int y, int b, int s) {
290N/A sampleModel.setSample(x-sampleModelTranslateX,
290N/A y-sampleModelTranslateY, b, s,
290N/A dataBuffer);
290N/A }
290N/A
290N/A /**
290N/A * Sets a sample in the specified band for the pixel located at (x,y)
290N/A * in the DataBuffer using a float for input.
290N/A * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
290N/A * not in bounds.
290N/A * However, explicit bounds checking is not guaranteed.
290N/A * @param x The X coordinate of the pixel location.
290N/A * @param y The Y coordinate of the pixel location.
290N/A * @param b The band to set.
290N/A * @param s The input sample as a float.
290N/A *
290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates or
290N/A * the band index are not in bounds.
290N/A */
290N/A public void setSample(int x, int y, int b, float s){
290N/A sampleModel.setSample(x-sampleModelTranslateX,y-sampleModelTranslateY,
290N/A b,s,dataBuffer);
290N/A }
290N/A
290N/A /**
290N/A * Sets a sample in the specified band for the pixel located at (x,y)
290N/A * in the DataBuffer using a double for input.
290N/A * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
290N/A * not in bounds.
290N/A * However, explicit bounds checking is not guaranteed.
290N/A * @param x The X coordinate of the pixel location.
290N/A * @param y The Y coordinate of the pixel location.
290N/A * @param b The band to set.
290N/A * @param s The input sample as a double.
290N/A *
290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates or
290N/A * the band index are not in bounds.
290N/A */
290N/A public void setSample(int x, int y, int b, double s){
290N/A sampleModel.setSample(x-sampleModelTranslateX,y-sampleModelTranslateY,
290N/A b,s,dataBuffer);
290N/A }
290N/A
290N/A /**
290N/A * Sets the samples in the specified band for the specified rectangle
290N/A * of pixels from an int array containing one sample per array element.
290N/A * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
290N/A * not in bounds.
290N/A * However, explicit bounds checking is not guaranteed.
290N/A * @param x The X coordinate of the upper left pixel location.
290N/A * @param y The Y coordinate of the upper left pixel location.
290N/A * @param w Width of the pixel rectangle.
290N/A * @param h Height of the pixel rectangle.
290N/A * @param b The band to set.
290N/A * @param iArray The input int sample array.
290N/A *
290N/A * @throws NullPointerException if iArray is null.
290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates or
290N/A * the band index are not in bounds, or if iArray is too small to
290N/A * hold the input.
290N/A */
290N/A public void setSamples(int x, int y, int w, int h, int b,
290N/A int iArray[]) {
290N/A sampleModel.setSamples(x-sampleModelTranslateX,y-sampleModelTranslateY,
290N/A w,h,b,iArray,dataBuffer);
290N/A }
290N/A
290N/A /**
290N/A * Sets the samples in the specified band for the specified rectangle
290N/A * of pixels from a float array containing one sample per array element.
290N/A * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
290N/A * not in bounds.
290N/A * However, explicit bounds checking is not guaranteed.
290N/A * @param x The X coordinate of the upper left pixel location.
290N/A * @param y The Y coordinate of the upper left pixel location.
290N/A * @param w Width of the pixel rectangle.
290N/A * @param h Height of the pixel rectangle.
290N/A * @param b The band to set.
290N/A * @param fArray The input float sample array.
290N/A *
290N/A * @throws NullPointerException if fArray is null.
290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates or
290N/A * the band index are not in bounds, or if fArray is too small to
290N/A * hold the input.
290N/A */
290N/A public void setSamples(int x, int y, int w, int h, int b,
290N/A float fArray[]) {
290N/A sampleModel.setSamples(x-sampleModelTranslateX,y-sampleModelTranslateY,
290N/A w,h,b,fArray,dataBuffer);
290N/A }
290N/A
290N/A /**
290N/A * Sets the samples in the specified band for the specified rectangle
290N/A * of pixels from a double array containing one sample per array element.
290N/A * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
290N/A * not in bounds.
290N/A * However, explicit bounds checking is not guaranteed.
290N/A * @param x The X coordinate of the upper left pixel location.
290N/A * @param y The Y coordinate of the upper left pixel location.
290N/A * @param w Width of the pixel rectangle.
290N/A * @param h Height of the pixel rectangle.
290N/A * @param b The band to set.
290N/A * @param dArray The input double sample array.
290N/A *
290N/A * @throws NullPointerException if dArray is null.
290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates or
290N/A * the band index are not in bounds, or if dArray is too small to
290N/A * hold the input.
290N/A */
290N/A public void setSamples(int x, int y, int w, int h, int b,
290N/A double dArray[]) {
290N/A sampleModel.setSamples(x-sampleModelTranslateX,y-sampleModelTranslateY,
290N/A w,h,b,dArray,dataBuffer);
290N/A }
290N/A
290N/A}