2362N/A * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/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 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/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 0N/A * This class defines a Raster with pixels consisting of one or more 32-bit 0N/A * data elements stored in close proximity to each other in a integer array. 0N/A * The bit precision per data element is that 0N/A * of the data type (that is, the bit precision for this raster is 32). 0N/A * There is only one pixel stride and one scanline stride for all 0N/A * bands. For a given pixel, all samples fit in N data elements and these 0N/A * N data elements hold samples for only one pixel. This type of Raster 0N/A * can be used with a PackedColorModel. 0N/A * For example, if there is only one data element per pixel, a 0N/A * SinglePixelPackedSampleModel can be used to represent multiple 0N/A * bands with a PackedColorModel (including a DirectColorModel) for 0N/A * color interpretation. 0N/A /** A cached copy of minX + width for use in bounds checks. */ 0N/A /** A cached copy of minY + height for use in bounds checks. */ 0N/A * Constructs a IntegerInterleavedRaster with the given SampleModel. 0N/A * The Raster's upper left corner is origin and it is the same 0N/A * size as the SampleModel. A DataBuffer large enough to describe the 0N/A * Raster is automatically created. SampleModel must be of type 0N/A * SinglePixelPackedSampleModel. 0N/A * @param sampleModel The SampleModel that specifies the layout. 0N/A * @param origin The Point that specified the origin. 0N/A * Constructs a IntegerInterleavedRaster with the given SampleModel 0N/A * and DataBuffer. The Raster's upper left corner is origin and 0N/A * it is the same sizes the SampleModel. The DataBuffer is not 0N/A * initialized and must be a DataBufferInt compatible with SampleModel. 0N/A * SampleModel must be of type SinglePixelPackedSampleModel. 0N/A * @param sampleModel The SampleModel that specifies the layout. 0N/A * @param dataBuffer The DataBufferInt that contains the image data. 0N/A * @param origin The Point that specifies the origin. 0N/A * Constructs a IntegerInterleavedRaster with the given SampleModel, 0N/A * DataBuffer, and parent. DataBuffer must be a DataBufferInt and 0N/A * SampleModel must be of type SinglePixelPackedSampleModel. 0N/A * When translated into the base Raster's 0N/A * coordinate system, aRegion must be contained by the base Raster. 0N/A * Origin is the coodinate in the new Raster's coordinate system of 0N/A * the origin of the base Raster. (The base Raster is the Raster's 0N/A * ancestor which has no parent.) 0N/A * Note that this constructor should generally be called by other 0N/A * constructors or create methods, it should not be used directly. 0N/A * @param sampleModel The SampleModel that specifies the layout. 0N/A * @param dataBuffer The DataBufferInt that contains the image data. 0N/A * @param aRegion The Rectangle that specifies the image area. 0N/A * @param origin The Point that specifies the origin. 0N/A * @param parent The parent (if any) of this raster. 0N/A "integer DataBuffers");
0N/A " SinglePixelPackedSampleModel");
0N/A * Returns a copy of the data offsets array. For each band the data offset 0N/A * is the index into the band's data array, of the first sample of the 0N/A * Returns data offset for the specified band. The data offset 0N/A * is the index into the data array in which the first sample 0N/A * of the first scanline is stored. 0N/A * Returns the scanline stride -- the number of data array elements between 0N/A * a given sample and the sample in the same column of the next row. 0N/A * Returns pixel stride -- the number of data array elements between two 0N/A * samples for the same band on the same scanline. 0N/A * Returns a reference to the data array. 0N/A * Returns the data elements for all bands at the specified 0N/A * An ArrayIndexOutOfBounds exception will be thrown at runtime 0N/A * if the pixel coordinate is out of bounds. 0N/A * A ClassCastException will be thrown if the input object is non null 0N/A * and references anything other than an array of transferType. 0N/A * @param x The X coordinate of the pixel location. 0N/A * @param y The Y coordinate of the pixel location. 0N/A * @param outData An object reference to an array of type defined by 0N/A * getTransferType() and length getNumDataElements(). 0N/A * If null an array of appropriate type and size will be 0N/A * @return An object reference to an array of type defined by 0N/A * getTransferType() with the request pixel data. 0N/A (
"Coordinate out of bounds!");
0N/A * Returns an array of data elements from the specified rectangular 0N/A * An ArrayIndexOutOfBounds exception will be thrown at runtime 0N/A * if the pixel coordinates are out of bounds. 0N/A * A ClassCastException will be thrown if the input object is non null 0N/A * and references anything other than an array of transferType. 0N/A * int[] bandData = (int[])raster.getDataElements(x, y, w, h, null); 0N/A * int numDataElements = raster.getNumDataElements(); 0N/A * int[] pixel = new int[numDataElements]; 0N/A * // To find a data element at location (x2, y2) 0N/A * System.arraycopy(bandData, ((y2-y)*w + (x2-x))*numDataElements, 0N/A * pixel, 0, numDataElements); 0N/A * @param x The X coordinate of the upper left pixel location. 0N/A * @param y The Y coordinate of the upper left pixel location. 0N/A * @param width Width of the pixel rectangle. 0N/A * @param height Height of the pixel rectangle. 0N/A * @param outData An object reference to an array of type defined by 0N/A * getTransferType() and length w*h*getNumDataElements(). 0N/A * If null an array of appropriate type and size will be 0N/A * @return An object reference to an array of type defined by 0N/A * getTransferType() with the request pixel data. 0N/A (
"Coordinate out of bounds!");
0N/A * Stores the data elements for all bands at the specified location. 0N/A * An ArrayIndexOutOfBounds exception will be thrown at runtime 0N/A * if the pixel coordinate is out of bounds. 0N/A * A ClassCastException will be thrown if the input object is non null 0N/A * and references anything other than an array of transferType. 0N/A * @param x The X coordinate of the pixel location. 0N/A * @param y The Y coordinate of the pixel location. 0N/A * @param inData An object reference to an array of type defined by 0N/A * getTransferType() and length getNumDataElements() 0N/A * containing the pixel data to place at x,y. 0N/A (
"Coordinate out of bounds!");
0N/A * Stores the Raster data at the specified location. 0N/A * The transferType of the inputRaster must match this raster. 0N/A * An ArrayIndexOutOfBoundsException will be thrown at runtime 0N/A * if the pixel coordinates are out of bounds. 0N/A * @param x The X coordinate of the pixel location. 0N/A * @param y The Y coordinate of the pixel location. 0N/A * @param inRaster Raster of data to place at x,y location. 0N/A (
"Coordinate out of bounds!");
0N/A * Stores the Raster data at the specified location. 0N/A * @param dstX The absolute X coordinate of the destination pixel 0N/A * that will receive a copy of the upper-left pixel of the 0N/A * @param dstY The absolute Y coordinate of the destination pixel 0N/A * that will receive a copy of the upper-left pixel of the 0N/A * @param width The number of pixels to store horizontally 0N/A * @param height The number of pixels to store vertically 0N/A * @param inRaster Raster of data to place at x,y location. 0N/A // Assume bounds checking has been performed previously 0N/A // Write inRaster (minX, minY) to (dstX, dstY) 0N/A // Extract the raster parameters 0N/A // Fastest case. We can copy scanlines 0N/A // Loop through all of the scanlines and copy the data 0N/A // Grab one scanline at a time 0N/A * Stores an array of data elements into the specified rectangular 0N/A * An ArrayIndexOutOfBounds exception will be thrown at runtime 0N/A * if the pixel coordinates are out of bounds. 0N/A * A ClassCastException will be thrown if the input object is non null 0N/A * and references anything other than an array of transferType. 0N/A * The data elements in the 0N/A * data array are assumed to be packed. That is, a data element 0N/A * for the nth band at location (x2, y2) would be found at: 0N/A * inData[((y2-y)*w + (x2-x))*numDataElements + n] 0N/A * @param x The X coordinate of the upper left pixel location. 0N/A * @param y The Y coordinate of the upper left pixel location. 0N/A * @param w Width of the pixel rectangle. 0N/A * @param h Height of the pixel rectangle. 0N/A * @param inData An object reference to an array of type defined by 0N/A * getTransferType() and length w*h*getNumDataElements() 0N/A * containing the pixel data to place between x,y and 0N/A (
"Coordinate out of bounds!");
0N/A * Creates a subraster given a region of the raster. The x and y 0N/A * coordinates specify the horizontal and vertical offsets 0N/A * from the upper-left corner of this raster to the upper-left corner 0N/A * of the subraster. A subset of the bands of the parent Raster may 0N/A * be specified. If this is null, then all the bands are present in the 0N/A * subRaster. A translation to the subRaster may also be specified. 0N/A * Note that the subraster will reference the same 0N/A * DataBuffer as the parent raster, but using different offsets. 0N/A * @param x X offset. 0N/A * @param y Y offset. 0N/A * @param width Width (in pixels) of the subraster. 0N/A * @param height Height (in pixels) of the subraster. 0N/A * @param x0 Translated X origin of the subraster. 0N/A * @param y0 Translated Y origin of the subraster. 0N/A * @param bandList Array of band indices. 0N/A * @exception RasterFormatException 0N/A * if the specified bounding box is outside of the parent raster. 0N/A * Creates a subraster given a region of the raster. The x and y 0N/A * coordinates specify the horizontal and vertical offsets 0N/A * from the upper-left corner of this raster to the upper-left corner 0N/A * of the subraster. A subset of the bands of the parent raster may 0N/A * be specified. If this is null, then all the bands are present in the 0N/A * subRaster. Note that the subraster will reference the same 0N/A * DataBuffer as the parent raster, but using different offsets. 0N/A * @param x X offset. 0N/A * @param y Y offset. 0N/A * @param width Width (in pixels) of the subraster. 0N/A * @param height Height (in pixels) of the subraster. 0N/A * @param x0 Translated X origin of the subRaster. 0N/A * @param y0 Translated Y origin of the subRaster. 0N/A * @param bandList Array of band indices. 0N/A * @exception RasterFormatException 0N/A * if the specified bounding box is outside of the parent raster. 0N/A * Creates a raster with the same band layout but using a different 0N/A * width and height, and with new zeroed data arrays. 0N/A if (w <=
0 || h <=
0) {
0N/A ((w <=
0) ?
"width" :
"height"));
0N/A * Creates a raster with the same data layout and the same 0N/A * width and height, and with new zeroed data arrays. If 0N/A * the raster is a subraster, this will call 0N/A * createCompatibleRaster(width, height). 0N/A// * For debugging... prints a region of a one-band IntegerInterleavedRaster 0N/A// public void print(int x, int y, int w, int h) { 0N/A// // REMIND: Only works for 1 band! 0N/A// System.out.println(this); 0N/A// int offset = dataOffsets[0] + y*scanlineStride + x*pixelStride; 0N/A// for (int yoff=0; yoff < h; yoff++, offset += scanlineStride) { 0N/A// System.out.print("Line "+(sampleModelTranslateY+y+yoff)+": "); 0N/A// for (int xoff = 0; xoff < w; xoff++, off+= pixelStride) { 0N/A// System.out.print(Integer.toHexString(data[off])+" "); 0N/A// System.out.println("");