blob: 920f8a225bc94b657ee898feee644df77f7b9efe [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2006-2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24/**
25 * @test
26 * @bug 6279846
27 * @summary Verifies that transform between the same ICC color spaces does not
28 * change pixels
29 * @run main ColorConvertTest
30 */
31
32import java.awt.image.*;
33import java.awt.color.ColorSpace;
34
35public class RGBColorConvertTest {
36
37 public static void main(String [] args) {
38 BufferedImage src =
39 new BufferedImage(256,3,BufferedImage.TYPE_INT_RGB);
40 BufferedImage dst =
41 new BufferedImage(256,3,BufferedImage.TYPE_INT_RGB);
42
43 for (int i = 0; i < 256; i++) {
44 src.setRGB(i,0,i);
45 src.setRGB(i,1,i << 8);
46 src.setRGB(i,2,i << 16);
47 }
48
49 ColorSpace srcColorSpace = src.getColorModel().getColorSpace();
50
51 ColorConvertOp op = new ColorConvertOp(srcColorSpace, srcColorSpace,
52 null);
53 op.filter(src, dst);
54
55 int errCount = 0;
56 for (int i = 0; i < src.getWidth(); i++) {
57 for (int j = 0; j < src.getHeight(); j++) {
58 int scol = src.getRGB(i,j);
59 int dcol = dst.getRGB(i,j);
60 if (scol != dcol) {
61 System.err.println("(" + i + "," + j + ") : " +
62 Integer.toHexString(scol) + "!=" +
63 Integer.toHexString(dcol));
64 errCount++;
65 }
66 }
67 }
68
69 if (errCount > 0) {
70 throw new RuntimeException(errCount + " pixels are changed by " +
71 "transform between the same ICC color " +
72 "spaces");
73 }
74 }
75}