jdk/src/share/classes/sun/awt/image/IntegerComponentRaster.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 16868 b5e2827ecc50
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.awt.image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.image.Raster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.image.WritableRaster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.image.RasterFormatException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.image.SampleModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.image.SinglePixelPackedSampleModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.image.DataBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.image.DataBufferInt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.Point;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * This class defines a Raster with pixels consisting of one or more 32-bit
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * data elements stored in close proximity to each other in a integer array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * The bit precision per data element is that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * of the data type (that is, the bit precision for this raster is 32).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * There is only one pixel stride and one scanline stride for all
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * bands.  For a given pixel, all samples fit in N data elements and these
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * N data elements hold samples for only one pixel.  This type of Raster
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * can be used with a PackedColorModel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * For example, if there is only one data element per pixel, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * SinglePixelPackedSampleModel can be used to represent multiple
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * bands with a PackedColorModel (including a DirectColorModel) for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * color interpretation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
public class IntegerComponentRaster extends SunWritableRaster {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    static final int TYPE_CUSTOM                = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    static final int TYPE_BYTE_SAMPLES          = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    static final int TYPE_USHORT_SAMPLES        = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    static final int TYPE_INT_SAMPLES           = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    static final int TYPE_BYTE_BANDED_SAMPLES   = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    static final int TYPE_USHORT_BANDED_SAMPLES = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    static final int TYPE_INT_BANDED_SAMPLES    = 6;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    static final int TYPE_BYTE_PACKED_SAMPLES   = 7;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    static final int TYPE_USHORT_PACKED_SAMPLES = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    static final int TYPE_INT_PACKED_SAMPLES    = 9;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    static final int TYPE_INT_8BIT_SAMPLES      = 10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    static final int TYPE_BYTE_BINARY_SAMPLES   = 11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /** private band offset for use by native code */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    protected int bandOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    /** Data offsets for each band of image data. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    protected int[]         dataOffsets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    /** Scanline stride of the image data contained in this Raster. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    protected int           scanlineStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /** Pixel stride of the image data contained in this Raster. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    protected int           pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /** The image data array. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    protected int[]         data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /** The number of data elements required to store a pixel. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    protected int           numDataElems;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    int type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    /** A cached copy of minX + width for use in bounds checks. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    private int maxX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /** A cached copy of minY + height for use in bounds checks. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    private int maxY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    static private native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        /* ensure that the necessary native libraries are loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        NativeLibLoader.loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *  Constructs a IntegerComponentRaster with the given SampleModel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     *  The Raster's upper left corner is origin and it is the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *  size as the SampleModel.  A DataBuffer large enough to describe the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *  Raster is automatically created.  SampleModel must be of type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     *  SinglePixelPackedSampleModel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *  @param sampleModel     The SampleModel that specifies the layout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *  @param origin          The Point that specified the origin.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public IntegerComponentRaster(SampleModel sampleModel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                                     Point origin) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        this(sampleModel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
             sampleModel.createDataBuffer(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
             new Rectangle(origin.x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                           origin.y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                           sampleModel.getWidth(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                           sampleModel.getHeight()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
             origin,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
             null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Constructs a IntegerComponentRaster with the given SampleModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * and DataBuffer.  The Raster's upper left corner is origin and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * it is the same sizes the SampleModel.  The DataBuffer is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * initialized and must be a DataBufferInt compatible with SampleModel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * SampleModel must be of type SinglePixelPackedSampleModel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @param sampleModel     The SampleModel that specifies the layout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @param dataBuffer      The DataBufferInt that contains the image data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @param origin          The Point that specifies the origin.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public IntegerComponentRaster(SampleModel sampleModel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                                     DataBuffer dataBuffer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                                     Point origin) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        this(sampleModel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
             dataBuffer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
             new Rectangle(origin.x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                           origin.y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                           sampleModel.getWidth(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                           sampleModel.getHeight()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
             origin,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
             null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * Constructs a IntegerComponentRaster with the given SampleModel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * DataBuffer, and parent.  DataBuffer must be a DataBufferInt and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * SampleModel must be of type SinglePixelPackedSampleModel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * When translated into the base Raster's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * coordinate system, aRegion must be contained by the base Raster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * Origin is the coodinate in the new Raster's coordinate system of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * the origin of the base Raster.  (The base Raster is the Raster's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * ancestor which has no parent.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * Note that this constructor should generally be called by other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * constructors or create methods, it should not be used directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @param sampleModel     The SampleModel that specifies the layout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @param dataBuffer      The DataBufferInt that contains the image data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @param aRegion         The Rectangle that specifies the image area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @param origin          The Point that specifies the origin.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @param parent          The parent (if any) of this raster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public IntegerComponentRaster(SampleModel sampleModel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                                     DataBuffer dataBuffer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                                     Rectangle aRegion,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                                     Point origin,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                                     IntegerComponentRaster parent){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        super(sampleModel,dataBuffer,aRegion,origin,parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        this.maxX = minX + width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        this.maxY = minY + height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        if (!(dataBuffer instanceof DataBufferInt)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
           throw new RasterFormatException("IntegerComponentRasters must have" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                "integer DataBuffers");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        DataBufferInt dbi = (DataBufferInt)dataBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        if (dbi.getNumBanks() != 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            throw new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                RasterFormatException("DataBuffer for IntegerComponentRasters"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                                      " must only have 1 bank.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        this.data = stealData(dbi, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        if (sampleModel instanceof SinglePixelPackedSampleModel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            SinglePixelPackedSampleModel sppsm =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                    (SinglePixelPackedSampleModel)sampleModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            int[] boffsets = sppsm.getBitOffsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            boolean notByteBoundary = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            for (int i=1; i < boffsets.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                if ((boffsets[i]%8) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    notByteBoundary = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            this.type = (notByteBoundary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                         ? IntegerComponentRaster.TYPE_INT_PACKED_SAMPLES
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                         : IntegerComponentRaster.TYPE_INT_8BIT_SAMPLES);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            this.scanlineStride = sppsm.getScanlineStride();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            this.pixelStride    = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            this.dataOffsets = new int[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            this.dataOffsets[0] = dbi.getOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            this.bandOffset = this.dataOffsets[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            int xOffset = aRegion.x - origin.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            int yOffset = aRegion.y - origin.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            dataOffsets[0] += xOffset+yOffset*scanlineStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            this.numDataElems = sppsm.getNumDataElements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            throw new RasterFormatException("IntegerComponentRasters must have"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                                            " SinglePixelPackedSampleModel");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        verify(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * Returns a copy of the data offsets array. For each band the data offset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * is the index into the band's data array, of the first sample of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * band.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    public int[] getDataOffsets() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        return (int[]) dataOffsets.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * Returns data offset for the specified band.  The data offset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * is the index into the data array in which the first sample
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * of the first scanline is stored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    public int getDataOffset(int band) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        return dataOffsets[band];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * Returns the scanline stride -- the number of data array elements between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * a given sample and the sample in the same column of the next row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    public int getScanlineStride() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        return scanlineStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * Returns pixel stride -- the number of data array elements  between two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * samples for the same band on the same scanline.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    public int getPixelStride() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        return pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * Returns a reference to the data array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    public int[] getDataStorage() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        return data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * Returns the data elements for all bands at the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * An ArrayIndexOutOfBounds exception will be thrown at runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * if the pixel coordinate is out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * A ClassCastException will be thrown if the input object is non null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * and references anything other than an array of transferType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * @param x        The X coordinate of the pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * @param y        The Y coordinate of the pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * @param outData  An object reference to an array of type defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     *                 getTransferType() and length getNumDataElements().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *                 If null an array of appropriate type and size will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     *                 allocated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * @return         An object reference to an array of type defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     *                 getTransferType() with the request pixel data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    public Object getDataElements(int x, int y, Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        if ((x < this.minX) || (y < this.minY) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            (x >= this.maxX) || (y >= this.maxY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            throw new ArrayIndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                ("Coordinate out of bounds!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        int outData[];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        if (obj == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            outData = new int[numDataElements];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            outData = (int[])obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        int off = (y-minY)*scanlineStride +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                  (x-minX)*pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        for (int band = 0; band < numDataElements; band++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            outData[band] = data[dataOffsets[band] + off];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        return outData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * Returns an array  of data elements from the specified rectangular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * region.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * An ArrayIndexOutOfBounds exception will be thrown at runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * if the pixel coordinates are out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * A ClassCastException will be thrown if the input object is non null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * and references anything other than an array of transferType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     *       int[] bandData = (int[])raster.getDataElements(x, y, w, h, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     *       int numDataElements = raster.getNumDataElements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *       int[] pixel = new int[numDataElements];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *       // To find a data element at location (x2, y2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     *       System.arraycopy(bandData, ((y2-y)*w + (x2-x))*numDataElements,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     *                        pixel, 0, numDataElements);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * @param x        The X coordinate of the upper left pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * @param y        The Y coordinate of the upper left pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * @param width    Width of the pixel rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * @param height   Height of the pixel rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * @param outData  An object reference to an array of type defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     *                 getTransferType() and length w*h*getNumDataElements().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     *                 If null an array of appropriate type and size will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     *                 allocated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * @return         An object reference to an array of type defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     *                 getTransferType() with the request pixel data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    public Object getDataElements(int x, int y, int w, int h, Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        if ((x < this.minX) || (y < this.minY) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            (x + w > this.maxX) || (y + h > this.maxY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            throw new ArrayIndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                ("Coordinate out of bounds!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        int outData[];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        if (obj instanceof int[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            outData = (int[])obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            outData = new int[numDataElements*w*h];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        int yoff = (y-minY)*scanlineStride +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                   (x-minX)*pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        int xoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        int off = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        int xstart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        int ystart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        for (ystart=0; ystart < h; ystart++, yoff += scanlineStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            xoff = yoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
            for (xstart=0; xstart < w; xstart++, xoff += pixelStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                for (int c = 0; c < numDataElements; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                    outData[off++] = data[dataOffsets[c] + xoff];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        return outData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * Stores the data elements for all bands at the specified location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * An ArrayIndexOutOfBounds exception will be thrown at runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * if the pixel coordinate is out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * A ClassCastException will be thrown if the input object is non null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * and references anything other than an array of transferType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @param x        The X coordinate of the pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * @param y        The Y coordinate of the pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * @param inData   An object reference to an array of type defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     *                 getTransferType() and length getNumDataElements()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     *                 containing the pixel data to place at x,y.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    public void setDataElements(int x, int y, Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        if ((x < this.minX) || (y < this.minY) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            (x >= this.maxX) || (y >= this.maxY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
            throw new ArrayIndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                ("Coordinate out of bounds!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        int inData[] = (int[])obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        int off = (y-minY)*scanlineStride +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                  (x-minX)*pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        for (int i = 0; i < numDataElements; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            data[dataOffsets[i] + off] = inData[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * Stores the Raster data at the specified location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * The transferType of the inputRaster must match this raster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * An ArrayIndexOutOfBoundsException will be thrown at runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * if the pixel coordinates are out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * @param x          The X coordinate of the pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * @param y          The Y coordinate of the pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * @param inRaster   Raster of data to place at x,y location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    public void setDataElements(int x, int y, Raster inRaster) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        int dstOffX = x + inRaster.getMinX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        int dstOffY = y + inRaster.getMinY();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        int width  = inRaster.getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        int height = inRaster.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            (dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            throw new ArrayIndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                ("Coordinate out of bounds!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        setDataElements(dstOffX, dstOffY, width, height, inRaster);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * Stores the Raster data at the specified location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * @param dstX The absolute X coordinate of the destination pixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * that will receive a copy of the upper-left pixel of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * inRaster
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * @param dstY The absolute Y coordinate of the destination pixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * that will receive a copy of the upper-left pixel of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * inRaster
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * @param width      The number of pixels to store horizontally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @param height     The number of pixels to store vertically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @param inRaster   Raster of data to place at x,y location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    private void setDataElements(int dstX, int dstY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                                 int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                                 Raster inRaster) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        // Assume bounds checking has been performed previously
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        if (width <= 0 || height <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        // Write inRaster (minX, minY) to (dstX, dstY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        int srcOffX = inRaster.getMinX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        int srcOffY = inRaster.getMinY();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        int tdata[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        if (inRaster instanceof IntegerComponentRaster &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
            (pixelStride == 1) && (numDataElements == 1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            IntegerComponentRaster ict = (IntegerComponentRaster) inRaster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            if (ict.getNumDataElements() != 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                throw new ArrayIndexOutOfBoundsException("Number of bands"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                                                         " does not match");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            // Extract the raster parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            tdata    = ict.getDataStorage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            int tss  = ict.getScanlineStride();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            int toff = ict.getDataOffset(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            int srcOffset = toff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
            int dstOffset = dataOffsets[0]+(dstY-minY)*scanlineStride+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                                           (dstX-minX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            // Fastest case.  We can copy scanlines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            if (ict.getPixelStride() == pixelStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                width *= pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                // Loop through all of the scanlines and copy the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                for (int startY=0; startY < height; startY++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                    System.arraycopy(tdata, srcOffset, data, dstOffset, width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                    srcOffset += tss;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                    dstOffset += scanlineStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        Object odata = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        for (int startY=0; startY < height; startY++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            odata = inRaster.getDataElements(srcOffX, srcOffY+startY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                                             width, 1, odata);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            setDataElements(dstX, dstY+startY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                            width, 1, odata);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * Stores an array of data elements into the specified rectangular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * region.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * An ArrayIndexOutOfBounds exception will be thrown at runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * if the pixel coordinates are out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * A ClassCastException will be thrown if the input object is non null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * and references anything other than an array of transferType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * The data elements in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * data array are assumed to be packed.  That is, a data element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * for the nth band at location (x2, y2) would be found at:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     *      inData[((y2-y)*w + (x2-x))*numDataElements + n]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * @param x        The X coordinate of the upper left pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * @param y        The Y coordinate of the upper left pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * @param w        Width of the pixel rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * @param h        Height of the pixel rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * @param inData   An object reference to an array of type defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     *                 getTransferType() and length w*h*getNumDataElements()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     *                 containing the pixel data to place between x,y and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     *                 x+h, y+h.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    public void setDataElements(int x, int y, int w, int h, Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        if ((x < this.minX) || (y < this.minY) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
            (x + w > this.maxX) || (y + h > this.maxY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            throw new ArrayIndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                ("Coordinate out of bounds!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        int inData[] = (int[])obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        int yoff = (y-minY)*scanlineStride +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                   (x-minX)*pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        int xoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        int off = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        int xstart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        int ystart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        for (ystart=0; ystart < h; ystart++, yoff += scanlineStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            xoff = yoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
            for (xstart=0; xstart < w; xstart++, xoff += pixelStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                for (int c = 0; c < numDataElements; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                    data[dataOffsets[c] + xoff] = inData[off++];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * Creates a subraster given a region of the raster.  The x and y
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * coordinates specify the horizontal and vertical offsets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * from the upper-left corner of this raster to the upper-left corner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * of the subraster.  A subset of the bands of the parent Raster may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * be specified.  If this is null, then all the bands are present in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * subRaster. A translation to the subRaster may also be specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * Note that the subraster will reference the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * DataBuffer as the parent raster, but using different offsets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * @param x               X offset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * @param y               Y offset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * @param width           Width (in pixels) of the subraster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * @param height          Height (in pixels) of the subraster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * @param x0              Translated X origin of the subraster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * @param y0              Translated Y origin of the subraster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * @param bandList        Array of band indices.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * @exception RasterFormatException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     *            if the specified bounding box is outside of the parent raster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    public WritableRaster createWritableChild (int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                                               int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                                               int x0, int y0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                                               int bandList[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        if (x < this.minX) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            throw new RasterFormatException("x lies outside raster");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        if (y < this.minY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            throw new RasterFormatException("y lies outside raster");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        if ((x+width < x) || (x+width > this.minX + this.width)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            throw new RasterFormatException("(x + width) is outside raster");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        if ((y+height < y) || (y+height > this.minY + this.height)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
            throw new RasterFormatException("(y + height) is outside raster");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        SampleModel sm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        if (bandList != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            sm = sampleModel.createSubsetSampleModel(bandList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            sm = sampleModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        int deltaX = x0 - x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        int deltaY = y0 - y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        return new IntegerComponentRaster(sm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                                          dataBuffer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                                          new Rectangle(x0,y0,width,height),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                                          new Point(sampleModelTranslateX+deltaX,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                                                    sampleModelTranslateY+deltaY),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                                          this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * Creates a subraster given a region of the raster.  The x and y
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * coordinates specify the horizontal and vertical offsets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * from the upper-left corner of this raster to the upper-left corner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * of the subraster.  A subset of the bands of the parent raster may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * be specified. If this is null, then all the bands are present in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * subRaster. Note that the subraster will reference the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * DataBuffer as the parent raster, but using different offsets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * @param x               X offset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * @param y               Y offset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     * @param width           Width (in pixels) of the subraster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * @param height          Height (in pixels) of the subraster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * @param x0              Translated X origin of the subRaster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * @param y0              Translated Y origin of the subRaster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * @param bandList        Array of band indices.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * @exception RasterFormatException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     *            if the specified bounding box is outside of the parent raster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    public Raster createChild (int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                               int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                               int x0, int y0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                               int bandList[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        return createWritableChild(x, y, width, height, x0, y0, bandList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * Creates a raster with the same band layout but using a different
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * width and height, and with new zeroed data arrays.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    public WritableRaster createCompatibleWritableRaster(int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        if (w <= 0 || h <=0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
            throw new RasterFormatException("negative "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                                          ((w <= 0) ? "width" : "height"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        SampleModel sm = sampleModel.createCompatibleSampleModel(w,h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        return new IntegerComponentRaster(sm, new Point(0,0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * Creates a raster with the same data layout and the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * width and height, and with new zeroed data arrays.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * the raster is a subraster, this will call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * createCompatibleRaster(width, height).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    public WritableRaster createCompatibleWritableRaster() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        return createCompatibleWritableRaster(width,height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * Verify that the layout parameters are consistent with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * the data.  If strictCheck
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * is false, this method will check for ArrayIndexOutOfBounds conditions.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * strictCheck is true, this method will check for additional error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * conditions such as line wraparound (width of a line greater than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     * the scanline stride).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * @return   String   Error string, if the layout is incompatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     *                    the data.  Otherwise returns null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    private void verify (boolean strictCheck) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        if (dataOffsets[0] < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            throw new RasterFormatException("Data offset ("+dataOffsets[0]+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
                                            ") must be >= 0");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        int maxSize = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        int size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        for (int i=0; i < numDataElements; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
            size = (height-1)*scanlineStride + (width-1)*pixelStride +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                dataOffsets[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
            if (size > maxSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                maxSize = size;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        if (data.length < maxSize) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
            throw new RasterFormatException("Data array too small (should be "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                                          maxSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                                          +" but is "+data.length+" )");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        return new String ("IntegerComponentRaster: width = "+width
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                           +" height = " + height
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                           +" #Bands = " + numBands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                           +" #DataElements "+numDataElements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                           +" xOff = "+sampleModelTranslateX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                           +" yOff = "+sampleModelTranslateY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                           +" dataOffset[0] "+dataOffsets[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
//    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
//     * For debugging...  prints a region of a one-band IntegerComponentRaster
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
//     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
//    public void print(int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
//        // REMIND:  Only works for 1 band!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
//        System.out.println(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
//        int offset = dataOffsets[0] + y*scanlineStride + x*pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
//        int off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
//        for (int yoff=0; yoff < h; yoff++, offset += scanlineStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
//            off = offset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
//            System.out.print("Line "+(sampleModelTranslateY+y+yoff)+": ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
//            for (int xoff = 0; xoff < w; xoff++, off+= pixelStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
//                System.out.print(Integer.toHexString(data[off])+" ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
//            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
//            System.out.println("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
//        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
//    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
}