Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/java2d/cmm/ColorConvertOp/InvalidRenderIntentTest.java
43305 views
1
/*
2
* Copyright (c) 2011, 2012, 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 7064516
27
* @summary Test verifies that incorrect profile rendering intent
28
* does not cause an failure of color conversion op.
29
* @run main InvalidRenderIntentTest
30
*/
31
32
import java.awt.color.CMMException;
33
import java.awt.color.ColorSpace;
34
import java.awt.color.ICC_ColorSpace;
35
import java.awt.color.ICC_Profile;
36
import java.awt.image.ColorConvertOp;
37
import java.awt.image.BufferedImage;
38
39
import static java.awt.color.ColorSpace.CS_sRGB;
40
import static java.awt.image.BufferedImage.TYPE_3BYTE_BGR;
41
42
public class InvalidRenderIntentTest {
43
44
public static void main(String[] args) {
45
ICC_Profile pSRGB = ICC_Profile.getInstance(CS_sRGB);
46
47
byte[] raw_data = pSRGB.getData();
48
49
setRenderingIntent(0x1000000, raw_data);
50
51
ICC_Profile p = ICC_Profile.getInstance(raw_data);
52
53
ICC_ColorSpace cs = new ICC_ColorSpace(p);
54
55
// perfrom test color conversion
56
ColorConvertOp op = new ColorConvertOp(cs,
57
ColorSpace.getInstance(CS_sRGB), null);
58
BufferedImage src = new BufferedImage(1, 1, TYPE_3BYTE_BGR);
59
BufferedImage dst = new BufferedImage(1, 1, TYPE_3BYTE_BGR);
60
61
try {
62
op.filter(src.getRaster(), dst.getRaster());
63
} catch (CMMException e) {
64
throw new RuntimeException("Test failed.", e);
65
}
66
System.out.println("Test passed.");
67
}
68
69
private static void setRenderingIntent(int intent, byte[] data) {
70
final int pos = ICC_Profile.icHdrRenderingIntent;
71
72
data[pos + 0] = (byte) (0xff & (intent >> 24));
73
data[pos + 1] = (byte) (0xff & (intent >> 16));
74
data[pos + 2] = (byte) (0xff & (intent >> 8));
75
data[pos + 3] = (byte) (0xff & (intent));
76
}
77
}
78
79