author | katleman |
Wed, 25 May 2011 13:32:36 -0700 | |
changeset 9734 | b33a24d77590 |
parent 7746 | 3cdbc9c4de5b |
child 23010 | 6dadb192ad81 |
permissions | -rw-r--r-- |
7746
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
1 |
/* |
9734
b33a24d77590
7044486: open jdk repos have files with incorrect copyright headers, which can end up in src bundles
katleman
parents:
7746
diff
changeset
|
2 |
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
7746
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
4 |
* |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
8 |
* |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
13 |
* accompanied this code). |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
14 |
* |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
18 |
* |
9734
b33a24d77590
7044486: open jdk repos have files with incorrect copyright headers, which can end up in src bundles
katleman
parents:
7746
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b33a24d77590
7044486: open jdk repos have files with incorrect copyright headers, which can end up in src bundles
katleman
parents:
7746
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
b33a24d77590
7044486: open jdk repos have files with incorrect copyright headers, which can end up in src bundles
katleman
parents:
7746
diff
changeset
|
21 |
* questions. |
b33a24d77590
7044486: open jdk repos have files with incorrect copyright headers, which can end up in src bundles
katleman
parents:
7746
diff
changeset
|
22 |
*/ |
7746
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
23 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
24 |
/* |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
25 |
* @test |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
26 |
* @bug 6782574 |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
27 |
* @summary Test verifies that incorrect sample masks are correctly handled |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
28 |
* by the constructor of the SinglePixelPackedSampleModel class |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
29 |
* and do not cause internal error in the medialib glue code. |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
30 |
* |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
31 |
* @run main IncorrectSampleMaskTest |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
32 |
*/ |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
33 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
34 |
import java.awt.geom.AffineTransform; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
35 |
import java.awt.image.AffineTransformOp; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
36 |
import java.awt.image.BufferedImageOp; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
37 |
import java.awt.image.DataBuffer; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
38 |
import java.awt.image.DataBufferByte; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
39 |
import java.awt.image.DataBufferInt; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
40 |
import java.awt.image.DataBufferUShort; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
41 |
import java.awt.image.Raster; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
42 |
import java.awt.image.RasterOp; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
43 |
import java.awt.image.WritableRaster; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
44 |
import java.awt.image.SinglePixelPackedSampleModel; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
45 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
46 |
public class IncorrectSampleMaskTest { |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
47 |
public static void main(String[] args) { |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
48 |
int[] dataTypes = new int[] { |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
49 |
DataBuffer.TYPE_BYTE, |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
50 |
DataBuffer.TYPE_USHORT, |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
51 |
DataBuffer.TYPE_INT }; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
52 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
53 |
for (int type : dataTypes) { |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
54 |
doTest(type); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
55 |
} |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
56 |
} |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
57 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
58 |
private static final int w = 100; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
59 |
private static final int h = 100; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
60 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
61 |
private static AffineTransform at = |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
62 |
AffineTransform.getScaleInstance(0.5, 0.5); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
63 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
64 |
private static RasterOp op = |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
65 |
new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
66 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
67 |
private static void doTest(int dataType) { |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
68 |
int maxSize = DataBuffer.getDataTypeSize(dataType); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
69 |
System.out.println("Type size: " + maxSize); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
70 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
71 |
int theMask = (int)(1L << (maxSize + 2)) - 1; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
72 |
System.out.printf("theMask=%x\n", theMask); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
73 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
74 |
SinglePixelPackedSampleModel sm = |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
75 |
new SinglePixelPackedSampleModel(dataType, w, h, |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
76 |
new int[] { theMask }); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
77 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
78 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
79 |
int[] sampleSize = sm.getSampleSize(); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
80 |
for (int s : sampleSize) { |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
81 |
if (s > maxSize) { |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
82 |
throw new RuntimeException("Test failed: sample size is too big:" + s); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
83 |
} |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
84 |
} |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
85 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
86 |
System.out.println("Test medialib..."); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
87 |
DataBuffer buf = createDataBuffer(dataType); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
88 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
89 |
WritableRaster wr = Raster.createWritableRaster(sm, buf, null); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
90 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
91 |
op.filter(wr, null); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
92 |
System.out.println("Test PASSED."); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
93 |
} |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
94 |
|
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
95 |
private static DataBuffer createDataBuffer(int type) { |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
96 |
switch (type) { |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
97 |
case DataBuffer.TYPE_BYTE: { |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
98 |
byte[] buf = new byte[w * h]; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
99 |
return new DataBufferByte(buf, buf.length); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
100 |
} |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
101 |
case DataBuffer.TYPE_USHORT: { |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
102 |
short[] buf = new short[w * h]; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
103 |
return new DataBufferUShort(buf, buf.length); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
104 |
} |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
105 |
case DataBuffer.TYPE_INT: { |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
106 |
int[] buf = new int[w * h]; |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
107 |
return new DataBufferInt(buf, buf.length); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
108 |
} |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
109 |
default : |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
110 |
throw new RuntimeException("Unsupported data type."); |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
111 |
} |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
112 |
} |
3cdbc9c4de5b
6782574: AffineTransformOp.filter(BufferedImage, BufferedImage) fails with InternalError
bae
parents:
diff
changeset
|
113 |
} |