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 * 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 * 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 * 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. 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 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 * 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 * <p> The constructors of this class are protected. To instantiate 290N/A * a WritableRaster, use one of the createWritableRaster factory methods 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 * 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 * 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 * 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 /** Returns the parent WritableRaster (if any) of this WritableRaster, 290N/A * @return the parent of this <code>WritableRaster</code>, or 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 * @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 * 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 * <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 * <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 * <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 * <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 * @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 * @throws RasterFormatException if <code>w</code> or 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 // 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 * 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 * 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 * @throws ArrayIndexOutOfBoundsException if the coordinates are not 290N/A * in bounds, or if inData is too small to hold the input. 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 * An ArrayIndexOutOfBoundsException may be thrown if the coordinates are 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 * @throws NullPointerException if inRaster is null. 290N/A * @throws ArrayIndexOutOfBoundsException if the coordinates are not 290N/A (
"Coordinate out of bounds!");
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 * 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 * @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 * 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 * 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 * 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 * 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 * 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 * @param srcRaster The Raster from which to copy pixels. 290N/A * @throws NullPointerException if srcRaster is null. 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 * @param dx The X translation factor from src space to dst space 290N/A * @param dy The Y translation factor from src space to dst space 290N/A * @param srcRaster The Raster from which to copy pixels. 290N/A * @throws NullPointerException if srcRaster is null. 290N/A // Grab one scanline at a time 290N/A // Grab one scanline at a time 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 * 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 * @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 * 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 * 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 * @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 * 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 * 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 * @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 * 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 * 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 * @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 * 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 * 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 * @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 * 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 * 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 * @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 * 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 * 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 * @throws ArrayIndexOutOfBoundsException if the coordinates or 290N/A * the band index are not in bounds. 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 * 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 * @throws ArrayIndexOutOfBoundsException if the coordinates or 290N/A * the band index are not in bounds. 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 * 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 * @throws ArrayIndexOutOfBoundsException if the coordinates or 290N/A * the band index are not in bounds. 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 * 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 * @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 * 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 * 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 * @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 * 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 * 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 * @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