Skip to content

Commit 79cae43

Browse files
committed
6528710: sRGB-ColorSpace to sRGB-ColorSpace Conversion
Reviewed-by: andrew Backport-of: abeddab991d71f4ea54665082ffcb284267d7f44
1 parent f929269 commit 79cae43

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright Amazon.com Inc. 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+
import java.awt.Color;
25+
import java.awt.color.ColorSpace;
26+
27+
/**
28+
* @test
29+
* @bug 6528710
30+
* @summary Verifies sRGB-ColorSpace to sRGB-ColorSpace conversion quality
31+
*/
32+
public final class SimpleSRGBConversionQualityTest {
33+
34+
public static void main(String[] args) {
35+
ColorSpace cspace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
36+
float fvalue[] = {1.0f, 1.0f, 1.0f};
37+
38+
Color c = new Color(cspace, fvalue, 1.0f);
39+
if (c.getRed() != 255 || c.getGreen() != 255 || c.getBlue() != 255) {
40+
throw new RuntimeException("Wrong color: " + c);
41+
}
42+
43+
float frgbvalue[] = cspace.toRGB(fvalue);
44+
for (int i = 0; i < 3; ++i) {
45+
if (frgbvalue[i] != 1.0f) {
46+
System.err.println(fvalue[i] + " -> " + frgbvalue[i]);
47+
throw new RuntimeException("Wrong value");
48+
}
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)