src/share/classes/sun/awt/image/ByteComponentRaster.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 190             this.dataOffsets = new int[1];
 191             this.dataOffsets[0] = dbOffset;
 192             int xOffset = aRegion.x - origin.x;
 193             int yOffset = aRegion.y - origin.y;
 194             dataOffsets[0] += xOffset*pixelStride+yOffset*scanlineStride;
 195         } else {
 196             throw new RasterFormatException("IntegerComponentRasters must " +
 197                 "have ComponentSampleModel or SinglePixelPackedSampleModel");
 198         }
 199         this.bandOffset = this.dataOffsets[0];
 200 
 201         verify();
 202     }
 203 
 204     /**
 205      * Returns a copy of the data offsets array. For each band the data offset
 206      * is the index into the band's data array, of the first sample of the
 207      * band.
 208      */
 209     public int[] getDataOffsets() {
 210         return (int[]) dataOffsets.clone();
 211     }
 212 
 213     /**
 214      * Returns the data offset for the specified band.  The data offset
 215      * is the index into the data array
 216      * in which the first sample of the first scanline is stored.
 217      * @param band  The band whose offset is returned.
 218      */
 219     public int getDataOffset(int band) {
 220         return dataOffsets[band];
 221     }
 222 
 223     /**
 224      * Returns the scanline stride -- the number of data array elements between
 225      * a given sample and the sample in the same column of the next row in the
 226      * same band.
 227      */
 228     public int getScanlineStride() {
 229         return scanlineStride;
 230     }


   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 190             this.dataOffsets = new int[1];
 191             this.dataOffsets[0] = dbOffset;
 192             int xOffset = aRegion.x - origin.x;
 193             int yOffset = aRegion.y - origin.y;
 194             dataOffsets[0] += xOffset*pixelStride+yOffset*scanlineStride;
 195         } else {
 196             throw new RasterFormatException("IntegerComponentRasters must " +
 197                 "have ComponentSampleModel or SinglePixelPackedSampleModel");
 198         }
 199         this.bandOffset = this.dataOffsets[0];
 200 
 201         verify();
 202     }
 203 
 204     /**
 205      * Returns a copy of the data offsets array. For each band the data offset
 206      * is the index into the band's data array, of the first sample of the
 207      * band.
 208      */
 209     public int[] getDataOffsets() {
 210         return dataOffsets.clone();
 211     }
 212 
 213     /**
 214      * Returns the data offset for the specified band.  The data offset
 215      * is the index into the data array
 216      * in which the first sample of the first scanline is stored.
 217      * @param band  The band whose offset is returned.
 218      */
 219     public int getDataOffset(int band) {
 220         return dataOffsets[band];
 221     }
 222 
 223     /**
 224      * Returns the scanline stride -- the number of data array elements between
 225      * a given sample and the sample in the same column of the next row in the
 226      * same band.
 227      */
 228     public int getScanlineStride() {
 229         return scanlineStride;
 230     }