45351
|
1 |
/*
|
|
2 |
* Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
/*
|
|
25 |
* @test
|
|
26 |
* @bug 4506450
|
|
27 |
* @summary Tests whether ImageTypeSpecifier.createBanded() and
|
|
28 |
* ImageTypeSpecifier.createInterleaved() can accept all supported
|
|
29 |
* DataBuffer types
|
|
30 |
*/
|
|
31 |
|
|
32 |
import java.awt.color.ColorSpace;
|
|
33 |
import java.awt.image.DataBuffer;
|
|
34 |
|
|
35 |
import javax.imageio.ImageTypeSpecifier;
|
|
36 |
|
|
37 |
public class ITSDataType {
|
|
38 |
|
|
39 |
public static final int[] dataTypes = new int[] {
|
|
40 |
DataBuffer.TYPE_BYTE,
|
|
41 |
DataBuffer.TYPE_SHORT,
|
|
42 |
DataBuffer.TYPE_USHORT,
|
|
43 |
DataBuffer.TYPE_INT,
|
|
44 |
DataBuffer.TYPE_FLOAT,
|
|
45 |
DataBuffer.TYPE_DOUBLE,
|
|
46 |
};
|
|
47 |
|
|
48 |
public static void main(String[] args) {
|
|
49 |
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
|
|
50 |
int[] bankIndices = new int[] { 1 };
|
|
51 |
int[] bandOffsets = new int[] { 0 };
|
|
52 |
|
|
53 |
// test createBanded()
|
|
54 |
for (int i = 0; i < dataTypes.length; i++) {
|
|
55 |
int dataType = dataTypes[i];
|
|
56 |
|
|
57 |
try {
|
|
58 |
ImageTypeSpecifier.createBanded(cs, bankIndices, bandOffsets,
|
|
59 |
dataType, false, false);
|
|
60 |
} catch (IllegalArgumentException e) {
|
|
61 |
throw new RuntimeException("createBanded() test failed for " +
|
|
62 |
"dataType = " + dataType);
|
|
63 |
}
|
|
64 |
}
|
|
65 |
|
|
66 |
// test createInterleaved()
|
|
67 |
for (int i = 0; i < dataTypes.length; i++) {
|
|
68 |
int dataType = dataTypes[i];
|
|
69 |
|
|
70 |
try {
|
|
71 |
ImageTypeSpecifier.createInterleaved(cs, bandOffsets,
|
|
72 |
dataType, false, false);
|
|
73 |
} catch (IllegalArgumentException e) {
|
|
74 |
throw new RuntimeException("createInterleaved() test failed " +
|
|
75 |
"for dataType = " + dataType);
|
|
76 |
}
|
|
77 |
}
|
|
78 |
}
|
|
79 |
}
|