author | tvaleev |
Thu, 04 Oct 2018 12:40:55 -0700 | |
changeset 52248 | 2e330da7cbf4 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1 |
/* |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
4 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
10 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
15 |
* accompanied this code). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
16 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
20 |
* |
5506 | 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 |
|
23 |
* questions. |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
24 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
25 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
26 |
/* **************************************************************** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
27 |
****************************************************************** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
28 |
****************************************************************** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
29 |
*** COPYRIGHT (c) Eastman Kodak Company, 1997 |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
30 |
*** As an unpublished work pursuant to Title 17 of the United |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
31 |
*** States Code. All rights reserved. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
32 |
****************************************************************** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
33 |
****************************************************************** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
34 |
******************************************************************/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
35 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
36 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
37 |
package java.awt.image; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
38 |
import java.awt.Rectangle; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
39 |
import java.awt.Point; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
40 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
41 |
import sun.awt.image.ByteInterleavedRaster; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
42 |
import sun.awt.image.ShortInterleavedRaster; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
43 |
import sun.awt.image.IntegerInterleavedRaster; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
44 |
import sun.awt.image.ByteBandedRaster; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
45 |
import sun.awt.image.ShortBandedRaster; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
46 |
import sun.awt.image.BytePackedRaster; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
47 |
import sun.awt.image.SunWritableRaster; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
48 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
49 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
50 |
* A class representing a rectangular array of pixels. A Raster |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
51 |
* encapsulates a DataBuffer that stores the sample values and a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
52 |
* SampleModel that describes how to locate a given sample value in a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
53 |
* DataBuffer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
54 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
55 |
* A Raster defines values for pixels occupying a particular |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
56 |
* rectangular area of the plane, not necessarily including (0, 0). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
57 |
* The rectangle, known as the Raster's bounding rectangle and |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
58 |
* available by means of the getBounds method, is defined by minX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
59 |
* minY, width, and height values. The minX and minY values define |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
60 |
* the coordinate of the upper left corner of the Raster. References |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
61 |
* to pixels outside of the bounding rectangle may result in an |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
62 |
* exception being thrown, or may result in references to unintended |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
63 |
* elements of the Raster's associated DataBuffer. It is the user's |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
64 |
* responsibility to avoid accessing such pixels. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
65 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
66 |
* A SampleModel describes how samples of a Raster |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
67 |
* are stored in the primitive array elements of a DataBuffer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
68 |
* Samples may be stored one per data element, as in a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
69 |
* PixelInterleavedSampleModel or BandedSampleModel, or packed several to |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
70 |
* an element, as in a SinglePixelPackedSampleModel or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
71 |
* MultiPixelPackedSampleModel. The SampleModel is also |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
72 |
* controls whether samples are sign extended, allowing unsigned |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
73 |
* data to be stored in signed Java data types such as byte, short, and |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
74 |
* int. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
75 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
76 |
* Although a Raster may live anywhere in the plane, a SampleModel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
77 |
* makes use of a simple coordinate system that starts at (0, 0). A |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
78 |
* Raster therefore contains a translation factor that allows pixel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
79 |
* locations to be mapped between the Raster's coordinate system and |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
80 |
* that of the SampleModel. The translation from the SampleModel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
81 |
* coordinate system to that of the Raster may be obtained by the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
82 |
* getSampleModelTranslateX and getSampleModelTranslateY methods. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
83 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
84 |
* A Raster may share a DataBuffer with another Raster either by |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
85 |
* explicit construction or by the use of the createChild and |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
86 |
* createTranslatedChild methods. Rasters created by these methods |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
87 |
* can return a reference to the Raster they were created from by |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
88 |
* means of the getParent method. For a Raster that was not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
89 |
* constructed by means of a call to createTranslatedChild or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
90 |
* createChild, getParent will return null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
91 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
92 |
* The createTranslatedChild method returns a new Raster that |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
93 |
* shares all of the data of the current Raster, but occupies a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
94 |
* bounding rectangle of the same width and height but with a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
95 |
* different starting point. For example, if the parent Raster |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
96 |
* occupied the region (10, 10) to (100, 100), and the translated |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
97 |
* Raster was defined to start at (50, 50), then pixel (20, 20) of the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
98 |
* parent and pixel (60, 60) of the child occupy the same location in |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
99 |
* the DataBuffer shared by the two Rasters. In the first case, (-10, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
100 |
* -10) should be added to a pixel coordinate to obtain the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
101 |
* corresponding SampleModel coordinate, and in the second case (-50, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
102 |
* -50) should be added. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
103 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
104 |
* The translation between a parent and child Raster may be |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
105 |
* determined by subtracting the child's sampleModelTranslateX and |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
106 |
* sampleModelTranslateY values from those of the parent. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
107 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
108 |
* The createChild method may be used to create a new Raster |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
109 |
* occupying only a subset of its parent's bounding rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
110 |
* (with the same or a translated coordinate system) or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
111 |
* with a subset of the bands of its parent. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
112 |
* <p> |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
113 |
* All constructors are protected. The correct way to create a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
114 |
* Raster is to use one of the static create methods defined in this |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
115 |
* class. These methods create instances of Raster that use the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
116 |
* standard Interleaved, Banded, and Packed SampleModels and that may |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
117 |
* be processed more efficiently than a Raster created by combining |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
118 |
* an externally generated SampleModel and DataBuffer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
119 |
* @see java.awt.image.DataBuffer |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
120 |
* @see java.awt.image.SampleModel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
121 |
* @see java.awt.image.PixelInterleavedSampleModel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
122 |
* @see java.awt.image.BandedSampleModel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
123 |
* @see java.awt.image.SinglePixelPackedSampleModel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
124 |
* @see java.awt.image.MultiPixelPackedSampleModel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
125 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
126 |
public class Raster { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
127 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
128 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
129 |
* The SampleModel that describes how pixels from this Raster |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
130 |
* are stored in the DataBuffer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
131 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
132 |
protected SampleModel sampleModel; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
133 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
134 |
/** The DataBuffer that stores the image data. */ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
135 |
protected DataBuffer dataBuffer; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
136 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
137 |
/** The X coordinate of the upper-left pixel of this Raster. */ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
138 |
protected int minX; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
139 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
140 |
/** The Y coordinate of the upper-left pixel of this Raster. */ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
141 |
protected int minY; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
142 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
143 |
/** The width of this Raster. */ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
144 |
protected int width; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
145 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
146 |
/** The height of this Raster. */ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
147 |
protected int height; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
148 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
149 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
150 |
* The X translation from the coordinate space of the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
151 |
* Raster's SampleModel to that of the Raster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
152 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
153 |
protected int sampleModelTranslateX; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
154 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
155 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
156 |
* The Y translation from the coordinate space of the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
157 |
* Raster's SampleModel to that of the Raster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
158 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
159 |
protected int sampleModelTranslateY; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
160 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
161 |
/** The number of bands in the Raster. */ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
162 |
protected int numBands; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
163 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
164 |
/** The number of DataBuffer data elements per pixel. */ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
165 |
protected int numDataElements; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
166 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
167 |
/** The parent of this Raster, or null. */ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
168 |
protected Raster parent; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
169 |
|
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
26749
diff
changeset
|
170 |
private static native void initIDs(); |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
171 |
static { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
172 |
ColorModel.loadLibraries(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
173 |
initIDs(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
174 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
175 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
176 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
177 |
* Creates a Raster based on a PixelInterleavedSampleModel with the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
178 |
* specified data type, width, height, and number of bands. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
179 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
180 |
* <p> The upper left corner of the Raster is given by the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
181 |
* location argument. If location is null, (0, 0) will be used. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
182 |
* The dataType parameter should be one of the enumerated values |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
183 |
* defined in the DataBuffer class. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
184 |
* |
35667 | 185 |
* <p> Note that interleaved {@code DataBuffer.TYPE_INT} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
186 |
* Rasters are not supported. To create a 1-band Raster of type |
35667 | 187 |
* {@code DataBuffer.TYPE_INT}, use |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
188 |
* Raster.createPackedRaster(). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
189 |
* <p> The only dataTypes supported currently are TYPE_BYTE |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
190 |
* and TYPE_USHORT. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
191 |
* @param dataType the data type for storing samples |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
192 |
* @param w the width in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
193 |
* @param h the height in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
194 |
* @param bands the number of bands |
35667 | 195 |
* @param location the upper-left corner of the {@code Raster} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
196 |
* @return a WritableRaster object with the specified data type, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
197 |
* width, height and number of bands. |
35667 | 198 |
* @throws RasterFormatException if {@code w} or {@code h} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
199 |
* is less than or equal to zero, or computing either |
35667 | 200 |
* {@code location.x + w} or |
201 |
* {@code location.y + h} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
202 |
* overflow |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
203 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
204 |
public static WritableRaster createInterleavedRaster(int dataType, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
205 |
int w, int h, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
206 |
int bands, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
207 |
Point location) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
208 |
int[] bandOffsets = new int[bands]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
209 |
for (int i = 0; i < bands; i++) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
210 |
bandOffsets[i] = i; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
211 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
212 |
return createInterleavedRaster(dataType, w, h, w*bands, bands, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
213 |
bandOffsets, location); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
214 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
215 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
216 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
217 |
* Creates a Raster based on a PixelInterleavedSampleModel with the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
218 |
* specified data type, width, height, scanline stride, pixel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
219 |
* stride, and band offsets. The number of bands is inferred from |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
220 |
* bandOffsets.length. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
221 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
222 |
* <p> The upper left corner of the Raster is given by the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
223 |
* location argument. If location is null, (0, 0) will be used. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
224 |
* The dataType parameter should be one of the enumerated values |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
225 |
* defined in the DataBuffer class. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
226 |
* |
35667 | 227 |
* <p> Note that interleaved {@code DataBuffer.TYPE_INT} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
228 |
* Rasters are not supported. To create a 1-band Raster of type |
35667 | 229 |
* {@code DataBuffer.TYPE_INT}, use |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
230 |
* Raster.createPackedRaster(). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
231 |
* <p> The only dataTypes supported currently are TYPE_BYTE |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
232 |
* and TYPE_USHORT. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
233 |
* @param dataType the data type for storing samples |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
234 |
* @param w the width in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
235 |
* @param h the height in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
236 |
* @param scanlineStride the line stride of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
237 |
* @param pixelStride the pixel stride of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
238 |
* @param bandOffsets the offsets of all bands |
35667 | 239 |
* @param location the upper-left corner of the {@code Raster} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
240 |
* @return a WritableRaster object with the specified data type, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
241 |
* width, height, scanline stride, pixel stride and band |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
242 |
* offsets. |
35667 | 243 |
* @throws RasterFormatException if {@code w} or {@code h} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
244 |
* is less than or equal to zero, or computing either |
35667 | 245 |
* {@code location.x + w} or |
246 |
* {@code location.y + h} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
247 |
* overflow |
35667 | 248 |
* @throws IllegalArgumentException if {@code dataType} is not |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
249 |
* one of the supported data types, which are |
35667 | 250 |
* {@code DataBuffer.TYPE_BYTE}, or |
251 |
* {@code DataBuffer.TYPE_USHORT}. |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
252 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
253 |
public static WritableRaster createInterleavedRaster(int dataType, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
254 |
int w, int h, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
255 |
int scanlineStride, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
256 |
int pixelStride, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
257 |
int[] bandOffsets, |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
258 |
Point location) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
259 |
DataBuffer d; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
260 |
|
18246 | 261 |
int size = scanlineStride * (h - 1) + // fisrt (h - 1) scans |
262 |
pixelStride * w; // last scan |
|
263 |
||
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
264 |
switch(dataType) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
265 |
case DataBuffer.TYPE_BYTE: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
266 |
d = new DataBufferByte(size); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
267 |
break; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
268 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
269 |
case DataBuffer.TYPE_USHORT: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
270 |
d = new DataBufferUShort(size); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
271 |
break; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
272 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
273 |
default: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
274 |
throw new IllegalArgumentException("Unsupported data type " + |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
275 |
dataType); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
276 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
277 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
278 |
return createInterleavedRaster(d, w, h, scanlineStride, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
279 |
pixelStride, bandOffsets, location); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
280 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
281 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
282 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
283 |
* Creates a Raster based on a BandedSampleModel with the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
284 |
* specified data type, width, height, and number of bands. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
285 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
286 |
* <p> The upper left corner of the Raster is given by the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
287 |
* location argument. If location is null, (0, 0) will be used. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
288 |
* The dataType parameter should be one of the enumerated values |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
289 |
* defined in the DataBuffer class. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
290 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
291 |
* <p> The only dataTypes supported currently are TYPE_BYTE, TYPE_USHORT, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
292 |
* and TYPE_INT. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
293 |
* @param dataType the data type for storing samples |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
294 |
* @param w the width in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
295 |
* @param h the height in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
296 |
* @param bands the number of bands |
35667 | 297 |
* @param location the upper-left corner of the {@code Raster} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
298 |
* @return a WritableRaster object with the specified data type, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
299 |
* width, height and number of bands. |
35667 | 300 |
* @throws RasterFormatException if {@code w} or {@code h} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
301 |
* is less than or equal to zero, or computing either |
35667 | 302 |
* {@code location.x + w} or |
303 |
* {@code location.y + h} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
304 |
* overflow |
35667 | 305 |
* @throws ArrayIndexOutOfBoundsException if {@code bands} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
306 |
* is less than 1 |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
307 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
308 |
public static WritableRaster createBandedRaster(int dataType, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
309 |
int w, int h, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
310 |
int bands, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
311 |
Point location) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
312 |
if (bands < 1) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
313 |
throw new ArrayIndexOutOfBoundsException("Number of bands ("+ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
314 |
bands+") must"+ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
315 |
" be greater than 0"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
316 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
317 |
int[] bankIndices = new int[bands]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
318 |
int[] bandOffsets = new int[bands]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
319 |
for (int i = 0; i < bands; i++) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
320 |
bankIndices[i] = i; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
321 |
bandOffsets[i] = 0; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
322 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
323 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
324 |
return createBandedRaster(dataType, w, h, w, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
325 |
bankIndices, bandOffsets, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
326 |
location); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
327 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
328 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
329 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
330 |
* Creates a Raster based on a BandedSampleModel with the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
331 |
* specified data type, width, height, scanline stride, bank |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
332 |
* indices and band offsets. The number of bands is inferred from |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
333 |
* bankIndices.length and bandOffsets.length, which must be the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
334 |
* same. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
335 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
336 |
* <p> The upper left corner of the Raster is given by the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
337 |
* location argument. The dataType parameter should be one of the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
338 |
* enumerated values defined in the DataBuffer class. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
339 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
340 |
* <p> The only dataTypes supported currently are TYPE_BYTE, TYPE_USHORT, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
341 |
* and TYPE_INT. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
342 |
* @param dataType the data type for storing samples |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
343 |
* @param w the width in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
344 |
* @param h the height in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
345 |
* @param scanlineStride the line stride of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
346 |
* @param bankIndices the bank indices for each band |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
347 |
* @param bandOffsets the offsets of all bands |
35667 | 348 |
* @param location the upper-left corner of the {@code Raster} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
349 |
* @return a WritableRaster object with the specified data type, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
350 |
* width, height, scanline stride, bank indices and band |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
351 |
* offsets. |
35667 | 352 |
* @throws RasterFormatException if {@code w} or {@code h} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
353 |
* is less than or equal to zero, or computing either |
35667 | 354 |
* {@code location.x + w} or |
355 |
* {@code location.y + h} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
356 |
* overflow |
35667 | 357 |
* @throws IllegalArgumentException if {@code dataType} is not |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
358 |
* one of the supported data types, which are |
35667 | 359 |
* {@code DataBuffer.TYPE_BYTE}, |
360 |
* {@code DataBuffer.TYPE_USHORT} |
|
361 |
* or {@code DataBuffer.TYPE_INT} |
|
362 |
* @throws ArrayIndexOutOfBoundsException if {@code bankIndices} |
|
363 |
* or {@code bandOffsets} is {@code null} |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
364 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
365 |
public static WritableRaster createBandedRaster(int dataType, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
366 |
int w, int h, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
367 |
int scanlineStride, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
368 |
int[] bankIndices, |
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
369 |
int[] bandOffsets, |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
370 |
Point location) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
371 |
DataBuffer d; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
372 |
int bands = bandOffsets.length; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
373 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
374 |
if (bankIndices == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
375 |
throw new |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
376 |
ArrayIndexOutOfBoundsException("Bank indices array is null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
377 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
378 |
if (bandOffsets == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
379 |
throw new |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
380 |
ArrayIndexOutOfBoundsException("Band offsets array is null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
381 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
382 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
383 |
// Figure out the #banks and the largest band offset |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
384 |
int maxBank = bankIndices[0]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
385 |
int maxBandOff = bandOffsets[0]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
386 |
for (int i = 1; i < bands; i++) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
387 |
if (bankIndices[i] > maxBank) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
388 |
maxBank = bankIndices[i]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
389 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
390 |
if (bandOffsets[i] > maxBandOff) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
391 |
maxBandOff = bandOffsets[i]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
392 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
393 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
394 |
int banks = maxBank + 1; |
18268
f7eca72008d4
8014427: REGRESSION: closed/javax/imageio/plugins/bmp/Write3ByteBgrTest.java fails since 7u25 b09
bae
parents:
18246
diff
changeset
|
395 |
int size = maxBandOff + |
26749 | 396 |
scanlineStride * (h - 1) + // first (h - 1) scans |
18246 | 397 |
w; // last scan |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
398 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
399 |
switch(dataType) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
400 |
case DataBuffer.TYPE_BYTE: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
401 |
d = new DataBufferByte(size, banks); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
402 |
break; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
403 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
404 |
case DataBuffer.TYPE_USHORT: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
405 |
d = new DataBufferUShort(size, banks); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
406 |
break; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
407 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
408 |
case DataBuffer.TYPE_INT: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
409 |
d = new DataBufferInt(size, banks); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
410 |
break; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
411 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
412 |
default: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
413 |
throw new IllegalArgumentException("Unsupported data type " + |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
414 |
dataType); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
415 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
416 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
417 |
return createBandedRaster(d, w, h, scanlineStride, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
418 |
bankIndices, bandOffsets, location); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
419 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
420 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
421 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
422 |
* Creates a Raster based on a SinglePixelPackedSampleModel with |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
423 |
* the specified data type, width, height, and band masks. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
424 |
* The number of bands is inferred from bandMasks.length. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
425 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
426 |
* <p> The upper left corner of the Raster is given by the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
427 |
* location argument. If location is null, (0, 0) will be used. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
428 |
* The dataType parameter should be one of the enumerated values |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
429 |
* defined in the DataBuffer class. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
430 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
431 |
* <p> The only dataTypes supported currently are TYPE_BYTE, TYPE_USHORT, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
432 |
* and TYPE_INT. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
433 |
* @param dataType the data type for storing samples |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
434 |
* @param w the width in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
435 |
* @param h the height in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
436 |
* @param bandMasks an array containing an entry for each band |
35667 | 437 |
* @param location the upper-left corner of the {@code Raster} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
438 |
* @return a WritableRaster object with the specified data type, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
439 |
* width, height, and band masks. |
35667 | 440 |
* @throws RasterFormatException if {@code w} or {@code h} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
441 |
* is less than or equal to zero, or computing either |
35667 | 442 |
* {@code location.x + w} or |
443 |
* {@code location.y + h} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
444 |
* overflow |
35667 | 445 |
* @throws IllegalArgumentException if {@code dataType} is not |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
446 |
* one of the supported data types, which are |
35667 | 447 |
* {@code DataBuffer.TYPE_BYTE}, |
448 |
* {@code DataBuffer.TYPE_USHORT} |
|
449 |
* or {@code DataBuffer.TYPE_INT} |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
450 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
451 |
public static WritableRaster createPackedRaster(int dataType, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
452 |
int w, int h, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
453 |
int[] bandMasks, |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
454 |
Point location) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
455 |
DataBuffer d; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
456 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
457 |
switch(dataType) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
458 |
case DataBuffer.TYPE_BYTE: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
459 |
d = new DataBufferByte(w*h); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
460 |
break; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
461 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
462 |
case DataBuffer.TYPE_USHORT: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
463 |
d = new DataBufferUShort(w*h); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
464 |
break; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
465 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
466 |
case DataBuffer.TYPE_INT: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
467 |
d = new DataBufferInt(w*h); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
468 |
break; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
469 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
470 |
default: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
471 |
throw new IllegalArgumentException("Unsupported data type " + |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
472 |
dataType); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
473 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
474 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
475 |
return createPackedRaster(d, w, h, w, bandMasks, location); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
476 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
477 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
478 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
479 |
* Creates a Raster based on a packed SampleModel with the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
480 |
* specified data type, width, height, number of bands, and bits |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
481 |
* per band. If the number of bands is one, the SampleModel will |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
482 |
* be a MultiPixelPackedSampleModel. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
483 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
484 |
* <p> If the number of bands is more than one, the SampleModel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
485 |
* will be a SinglePixelPackedSampleModel, with each band having |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
486 |
* bitsPerBand bits. In either case, the requirements on dataType |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
487 |
* and bitsPerBand imposed by the corresponding SampleModel must |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
488 |
* be met. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
489 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
490 |
* <p> The upper left corner of the Raster is given by the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
491 |
* location argument. If location is null, (0, 0) will be used. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
492 |
* The dataType parameter should be one of the enumerated values |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
493 |
* defined in the DataBuffer class. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
494 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
495 |
* <p> The only dataTypes supported currently are TYPE_BYTE, TYPE_USHORT, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
496 |
* and TYPE_INT. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
497 |
* @param dataType the data type for storing samples |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
498 |
* @param w the width in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
499 |
* @param h the height in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
500 |
* @param bands the number of bands |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
501 |
* @param bitsPerBand the number of bits per band |
35667 | 502 |
* @param location the upper-left corner of the {@code Raster} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
503 |
* @return a WritableRaster object with the specified data type, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
504 |
* width, height, number of bands, and bits per band. |
35667 | 505 |
* @throws RasterFormatException if {@code w} or {@code h} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
506 |
* is less than or equal to zero, or computing either |
35667 | 507 |
* {@code location.x + w} or |
508 |
* {@code location.y + h} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
509 |
* overflow |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
510 |
* @throws IllegalArgumentException if the product of |
35667 | 511 |
* {@code bitsPerBand} and {@code bands} is |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
512 |
* greater than the number of bits held by |
35667 | 513 |
* {@code dataType} |
514 |
* @throws IllegalArgumentException if {@code bitsPerBand} or |
|
515 |
* {@code bands} is not greater than zero |
|
516 |
* @throws IllegalArgumentException if {@code dataType} is not |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
517 |
* one of the supported data types, which are |
35667 | 518 |
* {@code DataBuffer.TYPE_BYTE}, |
519 |
* {@code DataBuffer.TYPE_USHORT} |
|
520 |
* or {@code DataBuffer.TYPE_INT} |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
521 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
522 |
public static WritableRaster createPackedRaster(int dataType, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
523 |
int w, int h, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
524 |
int bands, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
525 |
int bitsPerBand, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
526 |
Point location) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
527 |
DataBuffer d; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
528 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
529 |
if (bands <= 0) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
530 |
throw new IllegalArgumentException("Number of bands ("+bands+ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
531 |
") must be greater than 0"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
532 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
533 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
534 |
if (bitsPerBand <= 0) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
535 |
throw new IllegalArgumentException("Bits per band ("+bitsPerBand+ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
536 |
") must be greater than 0"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
537 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
538 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
539 |
if (bands != 1) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
540 |
int[] masks = new int[bands]; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
541 |
int mask = (1 << bitsPerBand) - 1; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
542 |
int shift = (bands-1)*bitsPerBand; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
543 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
544 |
/* Make sure the total mask size will fit in the data type */ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
545 |
if (shift+bitsPerBand > DataBuffer.getDataTypeSize(dataType)) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
546 |
throw new IllegalArgumentException("bitsPerBand("+ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
547 |
bitsPerBand+") * bands is "+ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
548 |
" greater than data type "+ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
549 |
"size."); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
550 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
551 |
switch(dataType) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
552 |
case DataBuffer.TYPE_BYTE: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
553 |
case DataBuffer.TYPE_USHORT: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
554 |
case DataBuffer.TYPE_INT: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
555 |
break; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
556 |
default: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
557 |
throw new IllegalArgumentException("Unsupported data type " + |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
558 |
dataType); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
559 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
560 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
561 |
for (int i = 0; i < bands; i++) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
562 |
masks[i] = mask << shift; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
563 |
shift = shift - bitsPerBand; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
564 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
565 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
566 |
return createPackedRaster(dataType, w, h, masks, location); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
567 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
568 |
else { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
569 |
double fw = w; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
570 |
switch(dataType) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
571 |
case DataBuffer.TYPE_BYTE: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
572 |
d = new DataBufferByte((int)(Math.ceil(fw/(8/bitsPerBand)))*h); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
573 |
break; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
574 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
575 |
case DataBuffer.TYPE_USHORT: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
576 |
d = new DataBufferUShort((int)(Math.ceil(fw/(16/bitsPerBand)))*h); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
577 |
break; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
578 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
579 |
case DataBuffer.TYPE_INT: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
580 |
d = new DataBufferInt((int)(Math.ceil(fw/(32/bitsPerBand)))*h); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
581 |
break; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
582 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
583 |
default: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
584 |
throw new IllegalArgumentException("Unsupported data type " + |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
585 |
dataType); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
586 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
587 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
588 |
return createPackedRaster(d, w, h, bitsPerBand, location); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
589 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
590 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
591 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
592 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
593 |
* Creates a Raster based on a PixelInterleavedSampleModel with the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
594 |
* specified DataBuffer, width, height, scanline stride, pixel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
595 |
* stride, and band offsets. The number of bands is inferred from |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
596 |
* bandOffsets.length. The upper left corner of the Raster |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
597 |
* is given by the location argument. If location is null, (0, 0) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
598 |
* will be used. |
35667 | 599 |
* <p> Note that interleaved {@code DataBuffer.TYPE_INT} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
600 |
* Rasters are not supported. To create a 1-band Raster of type |
35667 | 601 |
* {@code DataBuffer.TYPE_INT}, use |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
602 |
* Raster.createPackedRaster(). |
35667 | 603 |
* @param dataBuffer the {@code DataBuffer} that contains the |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
604 |
* image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
605 |
* @param w the width in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
606 |
* @param h the height in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
607 |
* @param scanlineStride the line stride of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
608 |
* @param pixelStride the pixel stride of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
609 |
* @param bandOffsets the offsets of all bands |
35667 | 610 |
* @param location the upper-left corner of the {@code Raster} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
611 |
* @return a WritableRaster object with the specified |
35667 | 612 |
* {@code DataBuffer}, width, height, scanline stride, |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
613 |
* pixel stride and band offsets. |
35667 | 614 |
* @throws RasterFormatException if {@code w} or {@code h} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
615 |
* is less than or equal to zero, or computing either |
35667 | 616 |
* {@code location.x + w} or |
617 |
* {@code location.y + h} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
618 |
* overflow |
35667 | 619 |
* @throws IllegalArgumentException if {@code dataType} is not |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
620 |
* one of the supported data types, which are |
35667 | 621 |
* {@code DataBuffer.TYPE_BYTE}, |
622 |
* {@code DataBuffer.TYPE_USHORT} |
|
623 |
* @throws RasterFormatException if {@code dataBuffer} has more |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
624 |
* than one bank. |
35667 | 625 |
* @throws NullPointerException if {@code dataBuffer} is null |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
626 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
627 |
public static WritableRaster createInterleavedRaster(DataBuffer dataBuffer, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
628 |
int w, int h, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
629 |
int scanlineStride, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
630 |
int pixelStride, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
631 |
int[] bandOffsets, |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
632 |
Point location) |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
633 |
{ |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
634 |
if (dataBuffer == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
635 |
throw new NullPointerException("DataBuffer cannot be null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
636 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
637 |
if (location == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
638 |
location = new Point(0, 0); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
639 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
640 |
int dataType = dataBuffer.getDataType(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
641 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
642 |
PixelInterleavedSampleModel csm = |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
643 |
new PixelInterleavedSampleModel(dataType, w, h, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
644 |
pixelStride, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
645 |
scanlineStride, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
646 |
bandOffsets); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
647 |
switch(dataType) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
648 |
case DataBuffer.TYPE_BYTE: |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
649 |
if (dataBuffer instanceof DataBufferByte) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
650 |
return new ByteInterleavedRaster(csm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
651 |
(DataBufferByte) dataBuffer, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
652 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
653 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
654 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
655 |
case DataBuffer.TYPE_USHORT: |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
656 |
if (dataBuffer instanceof DataBufferUShort) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
657 |
return new ShortInterleavedRaster(csm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
658 |
(DataBufferUShort) dataBuffer, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
659 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
660 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
661 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
662 |
default: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
663 |
throw new IllegalArgumentException("Unsupported data type " + |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
664 |
dataType); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
665 |
} |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
666 |
|
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
667 |
// Create the generic raster |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
668 |
return new SunWritableRaster(csm, dataBuffer, location); |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
669 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
670 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
671 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
672 |
* Creates a Raster based on a BandedSampleModel with the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
673 |
* specified DataBuffer, width, height, scanline stride, bank |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
674 |
* indices, and band offsets. The number of bands is inferred |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
675 |
* from bankIndices.length and bandOffsets.length, which must be |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
676 |
* the same. The upper left corner of the Raster is given by the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
677 |
* location argument. If location is null, (0, 0) will be used. |
35667 | 678 |
* @param dataBuffer the {@code DataBuffer} that contains the |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
679 |
* image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
680 |
* @param w the width in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
681 |
* @param h the height in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
682 |
* @param scanlineStride the line stride of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
683 |
* @param bankIndices the bank indices for each band |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
684 |
* @param bandOffsets the offsets of all bands |
35667 | 685 |
* @param location the upper-left corner of the {@code Raster} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
686 |
* @return a WritableRaster object with the specified |
35667 | 687 |
* {@code DataBuffer}, width, height, scanline stride, |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
688 |
* bank indices and band offsets. |
35667 | 689 |
* @throws RasterFormatException if {@code w} or {@code h} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
690 |
* is less than or equal to zero, or computing either |
35667 | 691 |
* {@code location.x + w} or |
692 |
* {@code location.y + h} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
693 |
* overflow |
35667 | 694 |
* @throws IllegalArgumentException if {@code dataType} is not |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
695 |
* one of the supported data types, which are |
35667 | 696 |
* {@code DataBuffer.TYPE_BYTE}, |
697 |
* {@code DataBuffer.TYPE_USHORT} |
|
698 |
* or {@code DataBuffer.TYPE_INT} |
|
699 |
* @throws NullPointerException if {@code dataBuffer} is null |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
700 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
701 |
public static WritableRaster createBandedRaster(DataBuffer dataBuffer, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
702 |
int w, int h, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
703 |
int scanlineStride, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
704 |
int[] bankIndices, |
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
705 |
int[] bandOffsets, |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
706 |
Point location) |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
707 |
{ |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
708 |
if (dataBuffer == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
709 |
throw new NullPointerException("DataBuffer cannot be null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
710 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
711 |
if (location == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
712 |
location = new Point(0,0); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
713 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
714 |
int dataType = dataBuffer.getDataType(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
715 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
716 |
int bands = bankIndices.length; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
717 |
if (bandOffsets.length != bands) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
718 |
throw new IllegalArgumentException( |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
719 |
"bankIndices.length != bandOffsets.length"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
720 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
721 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
722 |
BandedSampleModel bsm = |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
723 |
new BandedSampleModel(dataType, w, h, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
724 |
scanlineStride, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
725 |
bankIndices, bandOffsets); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
726 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
727 |
switch(dataType) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
728 |
case DataBuffer.TYPE_BYTE: |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
729 |
if (dataBuffer instanceof DataBufferByte) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
730 |
return new ByteBandedRaster(bsm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
731 |
(DataBufferByte) dataBuffer, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
732 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
733 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
734 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
735 |
case DataBuffer.TYPE_USHORT: |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
736 |
if (dataBuffer instanceof DataBufferUShort) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
737 |
return new ShortBandedRaster(bsm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
738 |
(DataBufferUShort) dataBuffer, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
739 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
740 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
741 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
742 |
case DataBuffer.TYPE_INT: |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
743 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
744 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
745 |
default: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
746 |
throw new IllegalArgumentException("Unsupported data type " + |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
747 |
dataType); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
748 |
} |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
749 |
|
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
750 |
// Create the generic raster |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
751 |
return new SunWritableRaster(bsm, dataBuffer, location); |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
752 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
753 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
754 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
755 |
* Creates a Raster based on a SinglePixelPackedSampleModel with |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
756 |
* the specified DataBuffer, width, height, scanline stride, and |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
757 |
* band masks. The number of bands is inferred from bandMasks.length. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
758 |
* The upper left corner of the Raster is given by |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
759 |
* the location argument. If location is null, (0, 0) will be used. |
35667 | 760 |
* @param dataBuffer the {@code DataBuffer} that contains the |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
761 |
* image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
762 |
* @param w the width in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
763 |
* @param h the height in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
764 |
* @param scanlineStride the line stride of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
765 |
* @param bandMasks an array containing an entry for each band |
35667 | 766 |
* @param location the upper-left corner of the {@code Raster} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
767 |
* @return a WritableRaster object with the specified |
35667 | 768 |
* {@code DataBuffer}, width, height, scanline stride, |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
769 |
* and band masks. |
35667 | 770 |
* @throws RasterFormatException if {@code w} or {@code h} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
771 |
* is less than or equal to zero, or computing either |
35667 | 772 |
* {@code location.x + w} or |
773 |
* {@code location.y + h} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
774 |
* overflow |
35667 | 775 |
* @throws IllegalArgumentException if {@code dataType} is not |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
776 |
* one of the supported data types, which are |
35667 | 777 |
* {@code DataBuffer.TYPE_BYTE}, |
778 |
* {@code DataBuffer.TYPE_USHORT} |
|
779 |
* or {@code DataBuffer.TYPE_INT} |
|
780 |
* @throws RasterFormatException if {@code dataBuffer} has more |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
781 |
* than one bank. |
35667 | 782 |
* @throws NullPointerException if {@code dataBuffer} is null |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
783 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
784 |
public static WritableRaster createPackedRaster(DataBuffer dataBuffer, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
785 |
int w, int h, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
786 |
int scanlineStride, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
787 |
int[] bandMasks, |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
788 |
Point location) |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
789 |
{ |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
790 |
if (dataBuffer == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
791 |
throw new NullPointerException("DataBuffer cannot be null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
792 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
793 |
if (location == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
794 |
location = new Point(0,0); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
795 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
796 |
int dataType = dataBuffer.getDataType(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
797 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
798 |
SinglePixelPackedSampleModel sppsm = |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
799 |
new SinglePixelPackedSampleModel(dataType, w, h, scanlineStride, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
800 |
bandMasks); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
801 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
802 |
switch(dataType) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
803 |
case DataBuffer.TYPE_BYTE: |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
804 |
if (dataBuffer instanceof DataBufferByte) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
805 |
return new ByteInterleavedRaster(sppsm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
806 |
(DataBufferByte) dataBuffer, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
807 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
808 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
809 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
810 |
case DataBuffer.TYPE_USHORT: |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
811 |
if (dataBuffer instanceof DataBufferUShort) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
812 |
return new ShortInterleavedRaster(sppsm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
813 |
(DataBufferUShort) dataBuffer, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
814 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
815 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
816 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
817 |
case DataBuffer.TYPE_INT: |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
818 |
if (dataBuffer instanceof DataBufferInt) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
819 |
return new IntegerInterleavedRaster(sppsm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
820 |
(DataBufferInt) dataBuffer, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
821 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
822 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
823 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
824 |
default: |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
825 |
throw new IllegalArgumentException("Unsupported data type " + |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
826 |
dataType); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
827 |
} |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
828 |
|
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
829 |
// Create the generic raster |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
830 |
return new SunWritableRaster(sppsm, dataBuffer, location); |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
831 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
832 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
833 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
834 |
* Creates a Raster based on a MultiPixelPackedSampleModel with the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
835 |
* specified DataBuffer, width, height, and bits per pixel. The upper |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
836 |
* left corner of the Raster is given by the location argument. If |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
837 |
* location is null, (0, 0) will be used. |
35667 | 838 |
* @param dataBuffer the {@code DataBuffer} that contains the |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
839 |
* image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
840 |
* @param w the width in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
841 |
* @param h the height in pixels of the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
842 |
* @param bitsPerPixel the number of bits for each pixel |
35667 | 843 |
* @param location the upper-left corner of the {@code Raster} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
844 |
* @return a WritableRaster object with the specified |
35667 | 845 |
* {@code DataBuffer}, width, height, and |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
846 |
* bits per pixel. |
35667 | 847 |
* @throws RasterFormatException if {@code w} or {@code h} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
848 |
* is less than or equal to zero, or computing either |
35667 | 849 |
* {@code location.x + w} or |
850 |
* {@code location.y + h} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
851 |
* overflow |
35667 | 852 |
* @throws IllegalArgumentException if {@code dataType} is not |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
853 |
* one of the supported data types, which are |
35667 | 854 |
* {@code DataBuffer.TYPE_BYTE}, |
855 |
* {@code DataBuffer.TYPE_USHORT} |
|
856 |
* or {@code DataBuffer.TYPE_INT} |
|
857 |
* @throws RasterFormatException if {@code dataBuffer} has more |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
858 |
* than one bank. |
35667 | 859 |
* @throws NullPointerException if {@code dataBuffer} is null |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
860 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
861 |
public static WritableRaster createPackedRaster(DataBuffer dataBuffer, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
862 |
int w, int h, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
863 |
int bitsPerPixel, |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
864 |
Point location) |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
865 |
{ |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
866 |
if (dataBuffer == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
867 |
throw new NullPointerException("DataBuffer cannot be null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
868 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
869 |
if (location == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
870 |
location = new Point(0,0); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
871 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
872 |
int dataType = dataBuffer.getDataType(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
873 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
874 |
if (dataType != DataBuffer.TYPE_BYTE && |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
875 |
dataType != DataBuffer.TYPE_USHORT && |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
876 |
dataType != DataBuffer.TYPE_INT) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
877 |
throw new IllegalArgumentException("Unsupported data type " + |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
878 |
dataType); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
879 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
880 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
881 |
if (dataBuffer.getNumBanks() != 1) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
882 |
throw new |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
883 |
RasterFormatException("DataBuffer for packed Rasters"+ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
884 |
" must only have 1 bank."); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
885 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
886 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
887 |
MultiPixelPackedSampleModel mppsm = |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
888 |
new MultiPixelPackedSampleModel(dataType, w, h, bitsPerPixel); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
889 |
|
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
890 |
if (dataBuffer instanceof DataBufferByte && |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
891 |
(bitsPerPixel == 1 || bitsPerPixel == 2 || bitsPerPixel == 4)) |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
892 |
{ |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
893 |
return new BytePackedRaster(mppsm, (DataBufferByte) dataBuffer, location); |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
894 |
} else { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
895 |
return new SunWritableRaster(mppsm, dataBuffer, location); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
896 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
897 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
898 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
899 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
900 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
901 |
* Creates a Raster with the specified SampleModel and DataBuffer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
902 |
* The upper left corner of the Raster is given by the location argument. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
903 |
* If location is null, (0, 0) will be used. |
35667 | 904 |
* @param sm the specified {@code SampleModel} |
905 |
* @param db the specified {@code DataBuffer} |
|
906 |
* @param location the upper-left corner of the {@code Raster} |
|
907 |
* @return a {@code Raster} with the specified |
|
908 |
* {@code SampleModel}, {@code DataBuffer}, and |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
909 |
* location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
910 |
* @throws RasterFormatException if computing either |
35667 | 911 |
* {@code location.x + sm.getWidth()} or |
912 |
* {@code location.y + sm.getHeight()} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
913 |
* overflow |
35667 | 914 |
* @throws RasterFormatException if {@code db} has more |
915 |
* than one bank and {@code sm} is a |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
916 |
* PixelInterleavedSampleModel, SinglePixelPackedSampleModel, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
917 |
* or MultiPixelPackedSampleModel. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
918 |
* @throws NullPointerException if either SampleModel or DataBuffer is |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
919 |
* null |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
920 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
921 |
public static Raster createRaster(SampleModel sm, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
922 |
DataBuffer db, |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
923 |
Point location) |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
924 |
{ |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
925 |
if ((sm == null) || (db == null)) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
926 |
throw new NullPointerException("SampleModel and DataBuffer cannot be null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
927 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
928 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
929 |
if (location == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
930 |
location = new Point(0,0); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
931 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
932 |
int dataType = sm.getDataType(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
933 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
934 |
if (sm instanceof PixelInterleavedSampleModel) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
935 |
switch(dataType) { |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
936 |
case DataBuffer.TYPE_BYTE: |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
937 |
if (db instanceof DataBufferByte) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
938 |
return new ByteInterleavedRaster(sm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
939 |
(DataBufferByte) db, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
940 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
941 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
942 |
|
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
943 |
case DataBuffer.TYPE_USHORT: |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
944 |
if (db instanceof DataBufferUShort) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
945 |
return new ShortInterleavedRaster(sm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
946 |
(DataBufferUShort) db, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
947 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
948 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
949 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
950 |
} else if (sm instanceof SinglePixelPackedSampleModel) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
951 |
switch(dataType) { |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
952 |
case DataBuffer.TYPE_BYTE: |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
953 |
if (db instanceof DataBufferByte) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
954 |
return new ByteInterleavedRaster(sm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
955 |
(DataBufferByte) db, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
956 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
957 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
958 |
|
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
959 |
case DataBuffer.TYPE_USHORT: |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
960 |
if (db instanceof DataBufferUShort) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
961 |
return new ShortInterleavedRaster(sm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
962 |
(DataBufferUShort) db, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
963 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
964 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
965 |
|
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
966 |
case DataBuffer.TYPE_INT: |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
967 |
if (db instanceof DataBufferInt) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
968 |
return new IntegerInterleavedRaster(sm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
969 |
(DataBufferInt) db, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
970 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
971 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
972 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
973 |
} else if (sm instanceof MultiPixelPackedSampleModel && |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
974 |
dataType == DataBuffer.TYPE_BYTE && |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
975 |
db instanceof DataBufferByte && |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
976 |
sm.getSampleSize(0) < 8) |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
977 |
{ |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
978 |
return new BytePackedRaster(sm, (DataBufferByte) db, location); |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
979 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
980 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
981 |
// we couldn't do anything special - do the generic thing |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
982 |
return new Raster(sm, db, location); |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
983 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
984 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
985 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
986 |
* Creates a WritableRaster with the specified SampleModel. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
987 |
* The upper left corner of the Raster is given by the location argument. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
988 |
* If location is null, (0, 0) will be used. |
35667 | 989 |
* @param sm the specified {@code SampleModel} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
990 |
* @param location the upper-left corner of the |
35667 | 991 |
* {@code WritableRaster} |
992 |
* @return a {@code WritableRaster} with the specified |
|
993 |
* {@code SampleModel} and location. |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
994 |
* @throws RasterFormatException if computing either |
35667 | 995 |
* {@code location.x + sm.getWidth()} or |
996 |
* {@code location.y + sm.getHeight()} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
997 |
* overflow |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
998 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
999 |
public static WritableRaster createWritableRaster(SampleModel sm, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1000 |
Point location) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1001 |
if (location == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1002 |
location = new Point(0,0); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1003 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1004 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1005 |
return createWritableRaster(sm, sm.createDataBuffer(), location); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1006 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1007 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1008 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1009 |
* Creates a WritableRaster with the specified SampleModel and DataBuffer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1010 |
* The upper left corner of the Raster is given by the location argument. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1011 |
* If location is null, (0, 0) will be used. |
35667 | 1012 |
* @param sm the specified {@code SampleModel} |
1013 |
* @param db the specified {@code DataBuffer} |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1014 |
* @param location the upper-left corner of the |
35667 | 1015 |
* {@code WritableRaster} |
1016 |
* @return a {@code WritableRaster} with the specified |
|
1017 |
* {@code SampleModel}, {@code DataBuffer}, and |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1018 |
* location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1019 |
* @throws RasterFormatException if computing either |
35667 | 1020 |
* {@code location.x + sm.getWidth()} or |
1021 |
* {@code location.y + sm.getHeight()} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1022 |
* overflow |
35667 | 1023 |
* @throws RasterFormatException if {@code db} has more |
1024 |
* than one bank and {@code sm} is a |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1025 |
* PixelInterleavedSampleModel, SinglePixelPackedSampleModel, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1026 |
* or MultiPixelPackedSampleModel. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1027 |
* @throws NullPointerException if either SampleModel or DataBuffer is null |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1028 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1029 |
public static WritableRaster createWritableRaster(SampleModel sm, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1030 |
DataBuffer db, |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1031 |
Point location) |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1032 |
{ |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1033 |
if ((sm == null) || (db == null)) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1034 |
throw new NullPointerException("SampleModel and DataBuffer cannot be null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1035 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1036 |
if (location == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1037 |
location = new Point(0,0); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1038 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1039 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1040 |
int dataType = sm.getDataType(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1041 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1042 |
if (sm instanceof PixelInterleavedSampleModel) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1043 |
switch(dataType) { |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1044 |
case DataBuffer.TYPE_BYTE: |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1045 |
if (db instanceof DataBufferByte) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1046 |
return new ByteInterleavedRaster(sm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1047 |
(DataBufferByte) db, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1048 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1049 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1050 |
|
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1051 |
case DataBuffer.TYPE_USHORT: |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1052 |
if (db instanceof DataBufferUShort) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1053 |
return new ShortInterleavedRaster(sm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1054 |
(DataBufferUShort) db, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1055 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1056 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1057 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1058 |
} else if (sm instanceof SinglePixelPackedSampleModel) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1059 |
switch(dataType) { |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1060 |
case DataBuffer.TYPE_BYTE: |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1061 |
if (db instanceof DataBufferByte) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1062 |
return new ByteInterleavedRaster(sm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1063 |
(DataBufferByte) db, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1064 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1065 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1066 |
|
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1067 |
case DataBuffer.TYPE_USHORT: |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1068 |
if (db instanceof DataBufferUShort) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1069 |
return new ShortInterleavedRaster(sm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1070 |
(DataBufferUShort) db, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1071 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1072 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1073 |
|
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1074 |
case DataBuffer.TYPE_INT: |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1075 |
if (db instanceof DataBufferInt) { |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1076 |
return new IntegerInterleavedRaster(sm, |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1077 |
(DataBufferInt) db, location); |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1078 |
} |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1079 |
break; |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1080 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1081 |
} else if (sm instanceof MultiPixelPackedSampleModel && |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1082 |
dataType == DataBuffer.TYPE_BYTE && |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1083 |
db instanceof DataBufferByte && |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1084 |
sm.getSampleSize(0) < 8) |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1085 |
{ |
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1086 |
return new BytePackedRaster(sm, (DataBufferByte) db, location); |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1087 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1088 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1089 |
// we couldn't do anything special - do the generic thing |
37544
d07afcfa7730
6353518: Creation of a WritableRaster with a custom DataBuffer causes erroneous Exception
aghaisas
parents:
35667
diff
changeset
|
1090 |
return new SunWritableRaster(sm, db, location); |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1091 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1092 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1093 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1094 |
* Constructs a Raster with the given SampleModel. The Raster's |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1095 |
* upper left corner is origin and it is the same size as the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1096 |
* SampleModel. A DataBuffer large enough to describe the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1097 |
* Raster is automatically created. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1098 |
* @param sampleModel The SampleModel that specifies the layout |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1099 |
* @param origin The Point that specified the origin |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1100 |
* @throws RasterFormatException if computing either |
35667 | 1101 |
* {@code origin.x + sampleModel.getWidth()} or |
1102 |
* {@code origin.y + sampleModel.getHeight()} results in |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1103 |
* integer overflow |
35667 | 1104 |
* @throws NullPointerException either {@code sampleModel} or |
1105 |
* {@code origin} is null |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1106 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1107 |
protected Raster(SampleModel sampleModel, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1108 |
Point origin) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1109 |
this(sampleModel, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1110 |
sampleModel.createDataBuffer(), |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1111 |
new Rectangle(origin.x, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1112 |
origin.y, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1113 |
sampleModel.getWidth(), |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1114 |
sampleModel.getHeight()), |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1115 |
origin, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1116 |
null); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1117 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1118 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1119 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1120 |
* Constructs a Raster with the given SampleModel and DataBuffer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1121 |
* The Raster's upper left corner is origin and it is the same size |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1122 |
* as the SampleModel. The DataBuffer is not initialized and must |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1123 |
* be compatible with SampleModel. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1124 |
* @param sampleModel The SampleModel that specifies the layout |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1125 |
* @param dataBuffer The DataBuffer that contains the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1126 |
* @param origin The Point that specifies the origin |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1127 |
* @throws RasterFormatException if computing either |
35667 | 1128 |
* {@code origin.x + sampleModel.getWidth()} or |
1129 |
* {@code origin.y + sampleModel.getHeight()} results in |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1130 |
* integer overflow |
35667 | 1131 |
* @throws NullPointerException either {@code sampleModel} or |
1132 |
* {@code origin} is null |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1133 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1134 |
protected Raster(SampleModel sampleModel, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1135 |
DataBuffer dataBuffer, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1136 |
Point origin) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1137 |
this(sampleModel, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1138 |
dataBuffer, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1139 |
new Rectangle(origin.x, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1140 |
origin.y, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1141 |
sampleModel.getWidth(), |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1142 |
sampleModel.getHeight()), |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1143 |
origin, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1144 |
null); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1145 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1146 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1147 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1148 |
* Constructs a Raster with the given SampleModel, DataBuffer, and |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1149 |
* parent. aRegion specifies the bounding rectangle of the new |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1150 |
* Raster. When translated into the base Raster's coordinate |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1151 |
* system, aRegion must be contained by the base Raster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1152 |
* (The base Raster is the Raster's ancestor which has no parent.) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1153 |
* sampleModelTranslate specifies the sampleModelTranslateX and |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1154 |
* sampleModelTranslateY values of the new Raster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1155 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1156 |
* Note that this constructor should generally be called by other |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1157 |
* constructors or create methods, it should not be used directly. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1158 |
* @param sampleModel The SampleModel that specifies the layout |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1159 |
* @param dataBuffer The DataBuffer that contains the image data |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1160 |
* @param aRegion The Rectangle that specifies the image area |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1161 |
* @param sampleModelTranslate The Point that specifies the translation |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1162 |
* from SampleModel to Raster coordinates |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1163 |
* @param parent The parent (if any) of this raster |
35667 | 1164 |
* @throws NullPointerException if any of {@code sampleModel}, |
1165 |
* {@code dataBuffer}, {@code aRegion} or |
|
1166 |
* {@code sampleModelTranslate} is null |
|
1167 |
* @throws RasterFormatException if {@code aRegion} has width |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1168 |
* or height less than or equal to zero, or computing either |
35667 | 1169 |
* {@code aRegion.x + aRegion.width} or |
1170 |
* {@code aRegion.y + aRegion.height} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1171 |
* overflow |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1172 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1173 |
protected Raster(SampleModel sampleModel, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1174 |
DataBuffer dataBuffer, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1175 |
Rectangle aRegion, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1176 |
Point sampleModelTranslate, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1177 |
Raster parent) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1178 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1179 |
if ((sampleModel == null) || (dataBuffer == null) || |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1180 |
(aRegion == null) || (sampleModelTranslate == null)) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1181 |
throw new NullPointerException("SampleModel, dataBuffer, aRegion and " + |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1182 |
"sampleModelTranslate cannot be null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1183 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1184 |
this.sampleModel = sampleModel; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1185 |
this.dataBuffer = dataBuffer; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1186 |
minX = aRegion.x; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1187 |
minY = aRegion.y; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1188 |
width = aRegion.width; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1189 |
height = aRegion.height; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1190 |
if (width <= 0 || height <= 0) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1191 |
throw new RasterFormatException("negative or zero " + |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1192 |
((width <= 0) ? "width" : "height")); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1193 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1194 |
if ((minX + width) < minX) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1195 |
throw new RasterFormatException( |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1196 |
"overflow condition for X coordinates of Raster"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1197 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1198 |
if ((minY + height) < minY) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1199 |
throw new RasterFormatException( |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1200 |
"overflow condition for Y coordinates of Raster"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1201 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1202 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1203 |
sampleModelTranslateX = sampleModelTranslate.x; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1204 |
sampleModelTranslateY = sampleModelTranslate.y; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1205 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1206 |
numBands = sampleModel.getNumBands(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1207 |
numDataElements = sampleModel.getNumDataElements(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1208 |
this.parent = parent; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1209 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1210 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1211 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1212 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1213 |
* Returns the parent Raster (if any) of this Raster or null. |
35667 | 1214 |
* @return the parent Raster or {@code null}. |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1215 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1216 |
public Raster getParent() { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1217 |
return parent; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1218 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1219 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1220 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1221 |
* Returns the X translation from the coordinate system of the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1222 |
* SampleModel to that of the Raster. To convert a pixel's X |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1223 |
* coordinate from the Raster coordinate system to the SampleModel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1224 |
* coordinate system, this value must be subtracted. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1225 |
* @return the X translation from the coordinate space of the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1226 |
* Raster's SampleModel to that of the Raster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1227 |
*/ |
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
26749
diff
changeset
|
1228 |
public final int getSampleModelTranslateX() { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1229 |
return sampleModelTranslateX; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1230 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1231 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1232 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1233 |
* Returns the Y translation from the coordinate system of the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1234 |
* SampleModel to that of the Raster. To convert a pixel's Y |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1235 |
* coordinate from the Raster coordinate system to the SampleModel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1236 |
* coordinate system, this value must be subtracted. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1237 |
* @return the Y translation from the coordinate space of the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1238 |
* Raster's SampleModel to that of the Raster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1239 |
*/ |
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
26749
diff
changeset
|
1240 |
public final int getSampleModelTranslateY() { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1241 |
return sampleModelTranslateY; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1242 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1243 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1244 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1245 |
* Create a compatible WritableRaster the same size as this Raster with |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1246 |
* the same SampleModel and a new initialized DataBuffer. |
35667 | 1247 |
* @return a compatible {@code WritableRaster} with the same sample |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1248 |
* model and a new data buffer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1249 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1250 |
public WritableRaster createCompatibleWritableRaster() { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1251 |
return new SunWritableRaster(sampleModel, new Point(0,0)); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1252 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1253 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1254 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1255 |
* Create a compatible WritableRaster with the specified size, a new |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1256 |
* SampleModel, and a new initialized DataBuffer. |
35667 | 1257 |
* @param w the specified width of the new {@code WritableRaster} |
1258 |
* @param h the specified height of the new {@code WritableRaster} |
|
1259 |
* @return a compatible {@code WritableRaster} with the specified |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1260 |
* size and a new sample model and data buffer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1261 |
* @exception RasterFormatException if the width or height is less than |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1262 |
* or equal to zero. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1263 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1264 |
public WritableRaster createCompatibleWritableRaster(int w, int h) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1265 |
if (w <= 0 || h <=0) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1266 |
throw new RasterFormatException("negative " + |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1267 |
((w <= 0) ? "width" : "height")); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1268 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1269 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1270 |
SampleModel sm = sampleModel.createCompatibleSampleModel(w,h); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1271 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1272 |
return new SunWritableRaster(sm, new Point(0,0)); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1273 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1274 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1275 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1276 |
* Create a compatible WritableRaster with location (minX, minY) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1277 |
* and size (width, height) specified by rect, a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1278 |
* new SampleModel, and a new initialized DataBuffer. |
35667 | 1279 |
* @param rect a {@code Rectangle} that specifies the size and |
1280 |
* location of the {@code WritableRaster} |
|
1281 |
* @return a compatible {@code WritableRaster} with the specified |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1282 |
* size and location and a new sample model and data buffer. |
35667 | 1283 |
* @throws RasterFormatException if {@code rect} has width |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1284 |
* or height less than or equal to zero, or computing either |
35667 | 1285 |
* {@code rect.x + rect.width} or |
1286 |
* {@code rect.y + rect.height} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1287 |
* overflow |
35667 | 1288 |
* @throws NullPointerException if {@code rect} is null |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1289 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1290 |
public WritableRaster createCompatibleWritableRaster(Rectangle rect) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1291 |
if (rect == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1292 |
throw new NullPointerException("Rect cannot be null"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1293 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1294 |
return createCompatibleWritableRaster(rect.x, rect.y, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1295 |
rect.width, rect.height); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1296 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1297 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1298 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1299 |
* Create a compatible WritableRaster with the specified |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1300 |
* location (minX, minY) and size (width, height), a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1301 |
* new SampleModel, and a new initialized DataBuffer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1302 |
* @param x the X coordinate of the upper-left corner of |
35667 | 1303 |
* the {@code WritableRaster} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1304 |
* @param y the Y coordinate of the upper-left corner of |
35667 | 1305 |
* the {@code WritableRaster} |
1306 |
* @param w the specified width of the {@code WritableRaster} |
|
1307 |
* @param h the specified height of the {@code WritableRaster} |
|
1308 |
* @return a compatible {@code WritableRaster} with the specified |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1309 |
* size and location and a new sample model and data buffer. |
35667 | 1310 |
* @throws RasterFormatException if {@code w} or {@code h} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1311 |
* is less than or equal to zero, or computing either |
35667 | 1312 |
* {@code x + w} or |
1313 |
* {@code y + h} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1314 |
* overflow |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1315 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1316 |
public WritableRaster createCompatibleWritableRaster(int x, int y, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1317 |
int w, int h) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1318 |
WritableRaster ret = createCompatibleWritableRaster(w, h); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1319 |
return ret.createWritableChild(0,0,w,h,x,y,null); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1320 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1321 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1322 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1323 |
* Create a Raster with the same size, SampleModel and DataBuffer |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1324 |
* as this one, but with a different location. The new Raster |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1325 |
* will possess a reference to the current Raster, accessible |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1326 |
* through its getParent() method. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1327 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1328 |
* @param childMinX the X coordinate of the upper-left |
35667 | 1329 |
* corner of the new {@code Raster} |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1330 |
* @param childMinY the Y coordinate of the upper-left |
35667 | 1331 |
* corner of the new {@code Raster} |
1332 |
* @return a new {@code Raster} with the same size, SampleModel, |
|
1333 |
* and DataBuffer as this {@code Raster}, but with the |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1334 |
* specified location. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1335 |
* @throws RasterFormatException if computing either |
35667 | 1336 |
* {@code childMinX + this.getWidth()} or |
1337 |
* {@code childMinY + this.getHeight()} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1338 |
* overflow |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1339 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1340 |
public Raster createTranslatedChild(int childMinX, int childMinY) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1341 |
return createChild(minX,minY,width,height, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1342 |
childMinX,childMinY,null); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1343 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1344 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1345 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1346 |
* Returns a new Raster which shares all or part of this Raster's |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1347 |
* DataBuffer. The new Raster will possess a reference to the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1348 |
* current Raster, accessible through its getParent() method. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1349 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1350 |
* <p> The parentX, parentY, width and height parameters |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1351 |
* form a Rectangle in this Raster's coordinate space, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1352 |
* indicating the area of pixels to be shared. An error will |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1353 |
* be thrown if this Rectangle is not contained with the bounds |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1354 |
* of the current Raster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1355 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1356 |
* <p> The new Raster may additionally be translated to a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1357 |
* different coordinate system for the plane than that used by the current |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1358 |
* Raster. The childMinX and childMinY parameters give the new |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1359 |
* (x, y) coordinate of the upper-left pixel of the returned |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1360 |
* Raster; the coordinate (childMinX, childMinY) in the new Raster |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1361 |
* will map to the same pixel as the coordinate (parentX, parentY) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1362 |
* in the current Raster. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1363 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1364 |
* <p> The new Raster may be defined to contain only a subset of |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1365 |
* the bands of the current Raster, possibly reordered, by means |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1366 |
* of the bandList parameter. If bandList is null, it is taken to |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1367 |
* include all of the bands of the current Raster in their current |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1368 |
* order. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1369 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1370 |
* <p> To create a new Raster that contains a subregion of the current |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1371 |
* Raster, but shares its coordinate system and bands, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1372 |
* this method should be called with childMinX equal to parentX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1373 |
* childMinY equal to parentY, and bandList equal to null. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1374 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1375 |
* @param parentX The X coordinate of the upper-left corner |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1376 |
* in this Raster's coordinates |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1377 |
* @param parentY The Y coordinate of the upper-left corner |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1378 |
* in this Raster's coordinates |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1379 |
* @param width Width of the region starting at (parentX, parentY) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1380 |
* @param height Height of the region starting at (parentX, parentY). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1381 |
* @param childMinX The X coordinate of the upper-left corner |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1382 |
* of the returned Raster |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1383 |
* @param childMinY The Y coordinate of the upper-left corner |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1384 |
* of the returned Raster |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1385 |
* @param bandList Array of band indices, or null to use all bands |
35667 | 1386 |
* @return a new {@code Raster}. |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1387 |
* @exception RasterFormatException if the specified subregion is outside |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1388 |
* of the raster bounds. |
35667 | 1389 |
* @throws RasterFormatException if {@code width} or |
1390 |
* {@code height} |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1391 |
* is less than or equal to zero, or computing any of |
35667 | 1392 |
* {@code parentX + width}, {@code parentY + height}, |
1393 |
* {@code childMinX + width}, or |
|
1394 |
* {@code childMinY + height} results in integer |
|
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1395 |
* overflow |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1396 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1397 |
public Raster createChild(int parentX, int parentY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1398 |
int width, int height, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1399 |
int childMinX, int childMinY, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
1400 |
int[] bandList) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1401 |
if (parentX < this.minX) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1402 |
throw new RasterFormatException("parentX lies outside raster"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1403 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1404 |
if (parentY < this.minY) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1405 |
throw new RasterFormatException("parentY lies outside raster"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1406 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1407 |
if ((parentX + width < parentX) || |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1408 |
(parentX + width > this.width + this.minX)) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1409 |
throw new RasterFormatException("(parentX + width) is outside raster"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1410 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1411 |
if ((parentY + height < parentY) || |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1412 |
(parentY + height > this.height + this.minY)) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1413 |
throw new RasterFormatException("(parentY + height) is outside raster"); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1414 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1415 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1416 |
SampleModel subSampleModel; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1417 |
// Note: the SampleModel for the child Raster should have the same |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1418 |
// width and height as that for the parent, since it represents |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1419 |
// the physical layout of the pixel data. The child Raster's width |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1420 |
// and height represent a "virtual" view of the pixel data, so |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1421 |
// they may be different than those of the SampleModel. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1422 |
if (bandList == null) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1423 |
subSampleModel = sampleModel; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1424 |
} else { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1425 |
subSampleModel = sampleModel.createSubsetSampleModel(bandList); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1426 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1427 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1428 |
int deltaX = childMinX - parentX; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1429 |
int deltaY = childMinY - parentY; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1430 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1431 |
return new Raster(subSampleModel, getDataBuffer(), |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1432 |
new Rectangle(childMinX, childMinY, width, height), |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1433 |
new Point(sampleModelTranslateX + deltaX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1434 |
sampleModelTranslateY + deltaY), this); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1435 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1436 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1437 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1438 |
* Returns the bounding Rectangle of this Raster. This function returns |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1439 |
* the same information as getMinX/MinY/Width/Height. |
35667 | 1440 |
* @return the bounding box of this {@code Raster}. |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1441 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1442 |
public Rectangle getBounds() { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1443 |
return new Rectangle(minX, minY, width, height); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1444 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1445 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1446 |
/** Returns the minimum valid X coordinate of the Raster. |
35667 | 1447 |
* @return the minimum x coordinate of this {@code Raster}. |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1448 |
*/ |
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
26749
diff
changeset
|
1449 |
public final int getMinX() { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1450 |
return minX; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1451 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1452 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1453 |
/** Returns the minimum valid Y coordinate of the Raster. |
35667 | 1454 |
* @return the minimum y coordinate of this {@code Raster}. |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1455 |
*/ |
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
26749
diff
changeset
|
1456 |
public final int getMinY() { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1457 |
return minY; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1458 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1459 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1460 |
/** Returns the width in pixels of the Raster. |
35667 | 1461 |
* @return the width of this {@code Raster}. |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1462 |
*/ |
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
26749
diff
changeset
|
1463 |
public final int getWidth() { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1464 |
return width; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1465 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1466 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1467 |
/** Returns the height in pixels of the Raster. |
35667 | 1468 |
* @return the height of this {@code Raster}. |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1469 |
*/ |
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
26749
diff
changeset
|
1470 |
public final int getHeight() { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1471 |
return height; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1472 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1473 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1474 |
/** Returns the number of bands (samples per pixel) in this Raster. |
35667 | 1475 |
* @return the number of bands of this {@code Raster}. |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1476 |
*/ |
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
26749
diff
changeset
|
1477 |
public final int getNumBands() { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1478 |
return numBands; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1479 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1480 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1481 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1482 |
* Returns the number of data elements needed to transfer one pixel |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1483 |
* via the getDataElements and setDataElements methods. When pixels |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1484 |
* are transferred via these methods, they may be transferred in a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1485 |
* packed or unpacked format, depending on the implementation of the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1486 |
* underlying SampleModel. Using these methods, pixels are transferred |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1487 |
* as an array of getNumDataElements() elements of a primitive type given |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1488 |
* by getTransferType(). The TransferType may or may not be the same |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1489 |
* as the storage data type of the DataBuffer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1490 |
* @return the number of data elements. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1491 |
*/ |
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
26749
diff
changeset
|
1492 |
public final int getNumDataElements() { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1493 |
return sampleModel.getNumDataElements(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1494 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1495 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1496 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1497 |
* Returns the TransferType used to transfer pixels via the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1498 |
* getDataElements and setDataElements methods. When pixels |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1499 |
* are transferred via these methods, they may be transferred in a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1500 |
* packed or unpacked format, depending on the implementation of the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1501 |
* underlying SampleModel. Using these methods, pixels are transferred |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1502 |
* as an array of getNumDataElements() elements of a primitive type given |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1503 |
* by getTransferType(). The TransferType may or may not be the same |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1504 |
* as the storage data type of the DataBuffer. The TransferType will |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1505 |
* be one of the types defined in DataBuffer. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1506 |
* @return this transfer type. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1507 |
*/ |
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
26749
diff
changeset
|
1508 |
public final int getTransferType() { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1509 |
return sampleModel.getTransferType(); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1510 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1511 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1512 |
/** Returns the DataBuffer associated with this Raster. |
35667 | 1513 |
* @return the {@code DataBuffer} of this {@code Raster}. |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1514 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1515 |
public DataBuffer getDataBuffer() { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1516 |
return dataBuffer; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1517 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1518 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1519 |
/** Returns the SampleModel that describes the layout of the image data. |
35667 | 1520 |
* @return the {@code SampleModel} of this {@code Raster}. |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1521 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1522 |
public SampleModel getSampleModel() { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1523 |
return sampleModel; |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1524 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1525 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1526 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1527 |
* Returns data for a single pixel in a primitive array of type |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1528 |
* TransferType. For image data supported by the Java 2D(tm) API, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1529 |
* this will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1530 |
* DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1531 |
* or DataBuffer.TYPE_DOUBLE. Data may be returned in a packed format, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1532 |
* thus increasing efficiency for data transfers. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1533 |
* An ArrayIndexOutOfBoundsException may be thrown |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1534 |
* if the coordinates are not in bounds. However, explicit bounds |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1535 |
* checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1536 |
* A ClassCastException will be thrown if the input object is non null |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1537 |
* and references anything other than an array of TransferType. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1538 |
* @see java.awt.image.SampleModel#getDataElements(int, int, Object, DataBuffer) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1539 |
* @param x The X coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1540 |
* @param y The Y coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1541 |
* @param outData An object reference to an array of type defined by |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1542 |
* getTransferType() and length getNumDataElements(). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1543 |
* If null, an array of appropriate type and size will be |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1544 |
* allocated |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1545 |
* @return An object reference to an array of type defined by |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1546 |
* getTransferType() with the requested pixel data. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1547 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1548 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1549 |
* in bounds, or if outData is too small to hold the output. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1550 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1551 |
public Object getDataElements(int x, int y, Object outData) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1552 |
return sampleModel.getDataElements(x - sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1553 |
y - sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1554 |
outData, dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1555 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1556 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1557 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1558 |
* Returns the pixel data for the specified rectangle of pixels in a |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1559 |
* primitive array of type TransferType. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1560 |
* For image data supported by the Java 2D API, this |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1561 |
* will be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1562 |
* DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1563 |
* or DataBuffer.TYPE_DOUBLE. Data may be returned in a packed format, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1564 |
* thus increasing efficiency for data transfers. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1565 |
* An ArrayIndexOutOfBoundsException may be thrown |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1566 |
* if the coordinates are not in bounds. However, explicit bounds |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1567 |
* checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1568 |
* A ClassCastException will be thrown if the input object is non null |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1569 |
* and references anything other than an array of TransferType. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1570 |
* @see java.awt.image.SampleModel#getDataElements(int, int, int, int, Object, DataBuffer) |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1571 |
* @param x The X coordinate of the upper-left pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1572 |
* @param y The Y coordinate of the upper-left pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1573 |
* @param w Width of the pixel rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1574 |
* @param h Height of the pixel rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1575 |
* @param outData An object reference to an array of type defined by |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1576 |
* getTransferType() and length w*h*getNumDataElements(). |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1577 |
* If null, an array of appropriate type and size will be |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1578 |
* allocated. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1579 |
* @return An object reference to an array of type defined by |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1580 |
* getTransferType() with the requested pixel data. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1581 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1582 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1583 |
* in bounds, or if outData is too small to hold the output. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1584 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1585 |
public Object getDataElements(int x, int y, int w, int h, Object outData) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1586 |
return sampleModel.getDataElements(x - sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1587 |
y - sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1588 |
w, h, outData, dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1589 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1590 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1591 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1592 |
* Returns the samples in an array of int for the specified pixel. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1593 |
* An ArrayIndexOutOfBoundsException may be thrown |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1594 |
* if the coordinates are not in bounds. However, explicit bounds |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1595 |
* checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1596 |
* @param x The X coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1597 |
* @param y The Y coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1598 |
* @param iArray An optionally preallocated int array |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1599 |
* @return the samples for the specified pixel. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1600 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1601 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1602 |
* in bounds, or if iArray is too small to hold the output. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1603 |
*/ |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
1604 |
public int[] getPixel(int x, int y, int[] iArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1605 |
return sampleModel.getPixel(x - sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1606 |
y - sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1607 |
iArray, dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1608 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1609 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1610 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1611 |
* Returns the samples in an array of float for the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1612 |
* specified pixel. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1613 |
* An ArrayIndexOutOfBoundsException may be thrown |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1614 |
* if the coordinates are not in bounds. However, explicit bounds |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1615 |
* checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1616 |
* @param x The X coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1617 |
* @param y The Y coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1618 |
* @param fArray An optionally preallocated float array |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1619 |
* @return the samples for the specified pixel. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1620 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1621 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1622 |
* in bounds, or if fArray is too small to hold the output. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1623 |
*/ |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
1624 |
public float[] getPixel(int x, int y, float[] fArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1625 |
return sampleModel.getPixel(x - sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1626 |
y - sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1627 |
fArray, dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1628 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1629 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1630 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1631 |
* Returns the samples in an array of double for the specified pixel. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1632 |
* An ArrayIndexOutOfBoundsException may be thrown |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1633 |
* if the coordinates are not in bounds. However, explicit bounds |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1634 |
* checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1635 |
* @param x The X coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1636 |
* @param y The Y coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1637 |
* @param dArray An optionally preallocated double array |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1638 |
* @return the samples for the specified pixel. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1639 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1640 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1641 |
* in bounds, or if dArray is too small to hold the output. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1642 |
*/ |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
1643 |
public double[] getPixel(int x, int y, double[] dArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1644 |
return sampleModel.getPixel(x - sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1645 |
y - sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1646 |
dArray, dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1647 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1648 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1649 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1650 |
* Returns an int array containing all samples for a rectangle of pixels, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1651 |
* one sample per array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1652 |
* An ArrayIndexOutOfBoundsException may be thrown |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1653 |
* if the coordinates are not in bounds. However, explicit bounds |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1654 |
* checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1655 |
* @param x The X coordinate of the upper-left pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1656 |
* @param y The Y coordinate of the upper-left pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1657 |
* @param w Width of the pixel rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1658 |
* @param h Height of the pixel rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1659 |
* @param iArray An optionally pre-allocated int array |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1660 |
* @return the samples for the specified rectangle of pixels. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1661 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1662 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1663 |
* in bounds, or if iArray is too small to hold the output. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1664 |
*/ |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
1665 |
public int[] getPixels(int x, int y, int w, int h, int[] iArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1666 |
return sampleModel.getPixels(x - sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1667 |
y - sampleModelTranslateY, w, h, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1668 |
iArray, dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1669 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1670 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1671 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1672 |
* Returns a float array containing all samples for a rectangle of pixels, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1673 |
* one sample per array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1674 |
* An ArrayIndexOutOfBoundsException may be thrown |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1675 |
* if the coordinates are not in bounds. However, explicit bounds |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1676 |
* checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1677 |
* @param x The X coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1678 |
* @param y The Y coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1679 |
* @param w Width of the pixel rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1680 |
* @param h Height of the pixel rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1681 |
* @param fArray An optionally pre-allocated float array |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1682 |
* @return the samples for the specified rectangle of pixels. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1683 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1684 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1685 |
* in bounds, or if fArray is too small to hold the output. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1686 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1687 |
public float[] getPixels(int x, int y, int w, int h, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
1688 |
float[] fArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1689 |
return sampleModel.getPixels(x - sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1690 |
y - sampleModelTranslateY, w, h, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1691 |
fArray, dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1692 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1693 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1694 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1695 |
* Returns a double array containing all samples for a rectangle of pixels, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1696 |
* one sample per array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1697 |
* An ArrayIndexOutOfBoundsException may be thrown |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1698 |
* if the coordinates are not in bounds. However, explicit bounds |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1699 |
* checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1700 |
* @param x The X coordinate of the upper-left pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1701 |
* @param y The Y coordinate of the upper-left pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1702 |
* @param w Width of the pixel rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1703 |
* @param h Height of the pixel rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1704 |
* @param dArray An optionally pre-allocated double array |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1705 |
* @return the samples for the specified rectangle of pixels. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1706 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1707 |
* @throws ArrayIndexOutOfBoundsException if the coordinates are not |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1708 |
* in bounds, or if dArray is too small to hold the output. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1709 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1710 |
public double[] getPixels(int x, int y, int w, int h, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
1711 |
double[] dArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1712 |
return sampleModel.getPixels(x - sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1713 |
y - sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1714 |
w, h, dArray, dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1715 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1716 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1717 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1718 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1719 |
* Returns the sample in a specified band for the pixel located |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1720 |
* at (x,y) as an int. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1721 |
* An ArrayIndexOutOfBoundsException may be thrown |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1722 |
* if the coordinates are not in bounds. However, explicit bounds |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1723 |
* checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1724 |
* @param x The X coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1725 |
* @param y The Y coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1726 |
* @param b The band to return |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1727 |
* @return the sample in the specified band for the pixel at the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1728 |
* specified coordinate. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1729 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1730 |
* @throws ArrayIndexOutOfBoundsException if the coordinates or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1731 |
* the band index are not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1732 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1733 |
public int getSample(int x, int y, int b) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1734 |
return sampleModel.getSample(x - sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1735 |
y - sampleModelTranslateY, b, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1736 |
dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1737 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1738 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1739 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1740 |
* Returns the sample in a specified band |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1741 |
* for the pixel located at (x,y) as a float. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1742 |
* An ArrayIndexOutOfBoundsException may be thrown |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1743 |
* if the coordinates are not in bounds. However, explicit bounds |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1744 |
* checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1745 |
* @param x The X coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1746 |
* @param y The Y coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1747 |
* @param b The band to return |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1748 |
* @return the sample in the specified band for the pixel at the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1749 |
* specified coordinate. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1750 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1751 |
* @throws ArrayIndexOutOfBoundsException if the coordinates or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1752 |
* the band index are not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1753 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1754 |
public float getSampleFloat(int x, int y, int b) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1755 |
return sampleModel.getSampleFloat(x - sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1756 |
y - sampleModelTranslateY, b, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1757 |
dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1758 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1759 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1760 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1761 |
* Returns the sample in a specified band |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1762 |
* for a pixel located at (x,y) as a double. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1763 |
* An ArrayIndexOutOfBoundsException may be thrown |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1764 |
* if the coordinates are not in bounds. However, explicit bounds |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1765 |
* checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1766 |
* @param x The X coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1767 |
* @param y The Y coordinate of the pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1768 |
* @param b The band to return |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1769 |
* @return the sample in the specified band for the pixel at the |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1770 |
* specified coordinate. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1771 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1772 |
* @throws ArrayIndexOutOfBoundsException if the coordinates or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1773 |
* the band index are not in bounds. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1774 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1775 |
public double getSampleDouble(int x, int y, int b) { |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1776 |
return sampleModel.getSampleDouble(x - sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1777 |
y - sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1778 |
b, dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1779 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1780 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1781 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1782 |
* Returns the samples for a specified band for the specified rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1783 |
* of pixels in an int array, one sample per array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1784 |
* An ArrayIndexOutOfBoundsException may be thrown |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1785 |
* if the coordinates are not in bounds. However, explicit bounds |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1786 |
* checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1787 |
* @param x The X coordinate of the upper-left pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1788 |
* @param y The Y coordinate of the upper-left pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1789 |
* @param w Width of the pixel rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1790 |
* @param h Height of the pixel rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1791 |
* @param b The band to return |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1792 |
* @param iArray An optionally pre-allocated int array |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1793 |
* @return the samples for the specified band for the specified |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1794 |
* rectangle of pixels. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1795 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1796 |
* @throws ArrayIndexOutOfBoundsException if the coordinates or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1797 |
* the band index are not in bounds, or if iArray is too small to |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1798 |
* hold the output. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1799 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1800 |
public int[] getSamples(int x, int y, int w, int h, int b, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
1801 |
int[] iArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1802 |
return sampleModel.getSamples(x - sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1803 |
y - sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1804 |
w, h, b, iArray, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1805 |
dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1806 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1807 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1808 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1809 |
* Returns the samples for a specified band for the specified rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1810 |
* of pixels in a float array, one sample per array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1811 |
* An ArrayIndexOutOfBoundsException may be thrown |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1812 |
* if the coordinates are not in bounds. However, explicit bounds |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1813 |
* checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1814 |
* @param x The X coordinate of the upper-left pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1815 |
* @param y The Y coordinate of the upper-left pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1816 |
* @param w Width of the pixel rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1817 |
* @param h Height of the pixel rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1818 |
* @param b The band to return |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1819 |
* @param fArray An optionally pre-allocated float array |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1820 |
* @return the samples for the specified band for the specified |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1821 |
* rectangle of pixels. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1822 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1823 |
* @throws ArrayIndexOutOfBoundsException if the coordinates or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1824 |
* the band index are not in bounds, or if fArray is too small to |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1825 |
* hold the output. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1826 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1827 |
public float[] getSamples(int x, int y, int w, int h, int b, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
1828 |
float[] fArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1829 |
return sampleModel.getSamples(x - sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1830 |
y - sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1831 |
w, h, b, fArray, dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1832 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1833 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1834 |
/** |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1835 |
* Returns the samples for a specified band for a specified rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1836 |
* of pixels in a double array, one sample per array element. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1837 |
* An ArrayIndexOutOfBoundsException may be thrown |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1838 |
* if the coordinates are not in bounds. However, explicit bounds |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1839 |
* checking is not guaranteed. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1840 |
* @param x The X coordinate of the upper-left pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1841 |
* @param y The Y coordinate of the upper-left pixel location |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1842 |
* @param w Width of the pixel rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1843 |
* @param h Height of the pixel rectangle |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1844 |
* @param b The band to return |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1845 |
* @param dArray An optionally pre-allocated double array |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1846 |
* @return the samples for the specified band for the specified |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1847 |
* rectangle of pixels. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1848 |
* |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1849 |
* @throws ArrayIndexOutOfBoundsException if the coordinates or |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1850 |
* the band index are not in bounds, or if dArray is too small to |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1851 |
* hold the output. |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1852 |
*/ |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1853 |
public double[] getSamples(int x, int y, int w, int h, int b, |
52248
2e330da7cbf4
8211300: Convert C-style array declarations in JDK client code
tvaleev
parents:
47216
diff
changeset
|
1854 |
double[] dArray) { |
539
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1855 |
return sampleModel.getSamples(x - sampleModelTranslateX, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1856 |
y - sampleModelTranslateY, |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1857 |
w, h, b, dArray, dataBuffer); |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1858 |
} |
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1859 |
|
7952521a4ad3
6662775: Move imaging and color classes from closed to open
prr
parents:
diff
changeset
|
1860 |
} |