1
2 /*
3 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
238 * The {@code IllegalArgumentException} might be thrown
239 * if the source {@code Raster} and the destination
240 * {@code Raster} do not have the same
241 * number of bands or if the number of arrays in the
242 * {@code LookupTable} does not meet the
243 * restrictions stated in the class comment above.
244 * @param src the source {@code Raster} to filter
245 * @param dst the destination {@code WritableRaster} for the
246 * filtered {@code src}
247 * @return the filtered {@code WritableRaster}.
248 * @throws IllegalArgumentException if the source and destinations
249 * rasters do not have the same number of bands, or the
250 * number of arrays in the {@code LookupTable} does
251 * not meet the restrictions described in the class comments.
252 *
253 */
254 public final WritableRaster filter (Raster src, WritableRaster dst) {
255 int numBands = src.getNumBands();
256 int height = src.getHeight();
257 int width = src.getWidth();
258 int srcPix[] = new int[numBands];
259
260 // Create a new destination Raster, if needed
261
262 if (dst == null) {
263 dst = createCompatibleDestRaster(src);
264 }
265 else if (height != dst.getHeight() || width != dst.getWidth()) {
266 throw new
267 IllegalArgumentException ("Width or height of Rasters do not "+
268 "match");
269 }
270 int dstLength = dst.getNumBands();
271
272 if (numBands != dstLength) {
273 throw new
274 IllegalArgumentException ("Number of channels in the src ("
275 + numBands +
276 ") does not match number of channels"
277 + " in the destination ("
278 + dstLength + ")");
|
1
2 /*
3 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Oracle designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Oracle in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
238 * The {@code IllegalArgumentException} might be thrown
239 * if the source {@code Raster} and the destination
240 * {@code Raster} do not have the same
241 * number of bands or if the number of arrays in the
242 * {@code LookupTable} does not meet the
243 * restrictions stated in the class comment above.
244 * @param src the source {@code Raster} to filter
245 * @param dst the destination {@code WritableRaster} for the
246 * filtered {@code src}
247 * @return the filtered {@code WritableRaster}.
248 * @throws IllegalArgumentException if the source and destinations
249 * rasters do not have the same number of bands, or the
250 * number of arrays in the {@code LookupTable} does
251 * not meet the restrictions described in the class comments.
252 *
253 */
254 public final WritableRaster filter (Raster src, WritableRaster dst) {
255 int numBands = src.getNumBands();
256 int height = src.getHeight();
257 int width = src.getWidth();
258 int[] srcPix = new int[numBands];
259
260 // Create a new destination Raster, if needed
261
262 if (dst == null) {
263 dst = createCompatibleDestRaster(src);
264 }
265 else if (height != dst.getHeight() || width != dst.getWidth()) {
266 throw new
267 IllegalArgumentException ("Width or height of Rasters do not "+
268 "match");
269 }
270 int dstLength = dst.getNumBands();
271
272 if (numBands != dstLength) {
273 throw new
274 IllegalArgumentException ("Number of channels in the src ("
275 + numBands +
276 ") does not match number of channels"
277 + " in the destination ("
278 + dstLength + ")");
|