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 0N/A * 8-bit data elements stored in close proximity to each other in a 0N/A * single byte array. 0N/A * The bit precision per data element is that of the data type (that 0N/A * is, the bit precision for this Raster is 8). There is only one 0N/A * pixel stride and one scanline stride for all bands. This type of 0N/A * Raster can be used with a ComponentColorModel if there are multiple 0N/A * bands, or an IndexColorModel if there is only one band. 0N/A /** True if the data offsets range from 0 to (pixelStride - 1) in order. */ 0N/A * The DataBuffer offset, minus sampleModelTranslateX*pixelStride, 0N/A * minus sampleModelTranslateY*scanlineStride, used to calculate 0N/A /** True if a SinglePixelPackedSampleModel is being used. */ 0N/A /** If packed == true, the SampleModel's bit masks. */ 0N/A /** If packed == true, the SampleModel's bit offsets. */ 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 ByteInterleavedRaster 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 or InterleavedSampleModel. 0N/A * @param sampleModel The SampleModel that specifies the layout. 0N/A * @param origin The Point that specified the origin. 0N/A * Constructs a ByteInterleavedRaster with the given SampleModel 0N/A * and DataBuffer. The Raster's upper left corner is origin and 0N/A * it is the same size as the SampleModel. The DataBuffer is not 0N/A * initialized and must be a DataBufferByte compatible with SampleModel. 0N/A * SampleModel must be of type SinglePixelPackedSampleModel 0N/A * or InterleavedSampleModel. 0N/A * @param sampleModel The SampleModel that specifies the layout. 0N/A * @param dataBuffer The DataBufferShort that contains the image data. 0N/A * @param origin The Point that specifies the origin. 0N/A /*** Analyzes a ComponentSampleModel to determine if it can function 0N/A * as a PixelInterleavedSampleModel. In order to do so, it must use 0N/A * only bank 0 of its DataBuffer, and the data offsets must span a range 0N/A * of less than pixelStride. 0N/A * <p> These properties are trivially true for a 1-banded SampleModel. 0N/A // Analyze ComponentSampleModel to determine if it has the 0N/A // properties of a PixelInterleavedSampleModel 0N/A // Determine banks used 0N/A // Determine range of band offsets 0N/A * Constructs a ByteInterleavedRaster with the given SampleModel, 0N/A * DataBuffer, and parent. DataBuffer must be a DataBufferByte and 0N/A * SampleModel must be of type SinglePixelPackedSampleModel 0N/A * or InterleavedSampleModel. 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 coordinate 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 DataBufferShort 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 "byte DataBuffers");
0N/A "have PixelInterleavedSampleModel, SinglePixelPackedSampleModel"+
0N/A " or interleaved ComponentSampleModel. Sample model is " +
0N/A // Set inOrder to true if the data elements are in order and 0N/A // have no gaps between them 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 the data offset for the specified band. The data offset 0N/A * is the index into the data array 0N/A * in which the first sample of the first scanline is stored. 0N/A * @param band The band whose offset is returned. 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 in the 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 * byte[] bandData = (byte[])raster.getDataElements(x, y, w, h, null); 0N/A * int numDataElements = raster.getNumDataElements(); 0N/A * byte[] pixel = new byte[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 * Returns a byte array of data elements from the specified rectangular 0N/A * region for the specified band. 0N/A * An ArrayIndexOutOfBounds exception will be thrown at runtime 0N/A * if the pixel coordinates are out of bounds. 0N/A * byte[] bandData = raster.getByteData(x, y, w, h, null); 0N/A * // To find the data element at location (x2, y2) 0N/A * byte bandElement = bandData[((y2-y)*w + (x2-x))]; 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 band The band to return. 0N/A * @param outData If non-null, data elements for all bands 0N/A * at the specified location are returned in this array. 0N/A * @return Data array with data elements for all bands. 0N/A // Bounds check for 'band' will be performed automatically 0N/A (
"Coordinate out of bounds!");
0N/A * Returns a byte 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 * byte[] bandData = raster.getByteData(x, y, w, h, null); 0N/A * int numDataElements = raster.getnumDataElements(); 0N/A * byte[] pixel = new byte[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 If non-null, data elements for all bands 0N/A * at the specified location are returned in this array. 0N/A * @return Data array with data elements for all bands. 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 * An ArrayIndexOutOfBounds exception 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 srcX The absolute X coordinate of the upper-left source 0N/A * pixel that will be copied into this Raster 0N/A * @param srcY The absolute Y coordinate of the upper-left source 0N/A * pixel that will be copied into this Raster 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 // copy whole scanlines 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 * Stores a byte array of data elements into the specified rectangular 0N/A * region for the specified band. 0N/A * An ArrayIndexOutOfBounds exception will be thrown at runtime 0N/A * if the pixel coordinates are out of bounds. 0N/A * The data elements in the 0N/A * data array are assumed to be packed. That is, a data element 0N/A * at location (x2, y2) would be found at: 0N/A * inData[((y2-y)*w + (x2-x)) + 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 band The band to set. 0N/A * @param inData The data elements to be stored. 0N/A // Bounds check for 'band' will be performed automatically 0N/A (
"Coordinate out of bounds!");
0N/A * Stores a byte 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 * 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 The data elements to be stored. 0N/A (
"Coordinate out of bounds!");
0N/A (
"Coordinate out of bounds!");
0N/A (
"Coordinate out of bounds!");
0N/A (
"Coordinate out of bounds!");
0N/A for (
int j =
0; j < h; j++) {
0N/A for (
int i =
0; i < w; i++) {
0N/A for (
int j =
0; j < h; j++) {
0N/A for (
int i =
0; i < w; i++) {
0N/A (
"Coordinate out of bounds!");
0N/A for (
int j =
0; j < h; j++) {
0N/A for (
int i =
0; i < w; i++) {
0N/A for (
int i =
0; i < h; i++) {
0N/A for (
int j =
0; j < w; j++) {
0N/A (
"Coordinate out of bounds!");
0N/A for (
int j =
0; j < h; j++) {
0N/A for (
int i =
0; i < w; i++) {
0N/A for (
int j =
0; j < h; j++) {
0N/A for (
int i =
0; i < w; i++) {
0N/A for (
int j =
0; j < h; j++) {
0N/A for (
int i =
0; i < w; i++) {
0N/A for (
int j =
0; j < h; j++) {
0N/A for (
int i =
0; i < w; i++) {
0N/A for (
int j =
0; j < h; j++) {
0N/A for (
int i =
0; i < w; i++) {
0N/A for (
int j =
0; j < h; j++) {
0N/A for (
int i =
0; i < w; i++) {
0N/A (
"Coordinate out of bounds!");
0N/A for (
int j =
0; j < h; j++) {
0N/A for (
int i =
0; i < w; i++) {
0N/A for (
int j =
0; j < h; j++) {
0N/A for (
int i =
0; i < w; i++) {
0N/A for (
int j =
0; j < h; j++) {
0N/A for (
int i =
0; i < w; i++) {
0N/A for (
int j =
0; j < h; j++) {
0N/A for (
int i =
0; i < w; i++) {
0N/A for (
int j =
0; j < h; j++) {
0N/A for (
int i =
0; i < w; i++) {
0N/A for (
int j =
0; j < h; j++) {
0N/A for (
int i =
0; i < w; i++) {
0N/A // Clip to this 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. 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 Writable 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 Raster with the same 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 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 return new String (
"ByteInterleavedRaster: width = "+
width+
" height = " 0N/A // +" xOff = "+xOffset+" yOff = "+yOffset 0N/A// * For debugging... prints a region of a one-band ByteInterleavedRaster 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 "+(y+yoff)+": "); 0N/A// for (int xoff = 0; xoff < w; xoff++, off+= pixelStride) { 0N/A// String s = Integer.toHexString(data[off]); 0N/A// if (s.length() == 8) { 0N/A// s = s.substring(6,8); 0N/A// System.out.print(s+" "); 0N/A// System.out.println("");