0N/A/*
2362N/A * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/**
0N/A * @test
0N/A * @bug 6279846
0N/A * @summary Verifies that transform between the same ICC color spaces does not
0N/A * change pixels
0N/A * @run main ColorConvertTest
0N/A */
0N/A
0N/Aimport java.awt.image.*;
0N/Aimport java.awt.color.ColorSpace;
0N/A
0N/Apublic class RGBColorConvertTest {
0N/A
0N/A public static void main(String [] args) {
0N/A BufferedImage src =
0N/A new BufferedImage(256,3,BufferedImage.TYPE_INT_RGB);
0N/A BufferedImage dst =
0N/A new BufferedImage(256,3,BufferedImage.TYPE_INT_RGB);
0N/A
0N/A for (int i = 0; i < 256; i++) {
0N/A src.setRGB(i,0,i);
0N/A src.setRGB(i,1,i << 8);
0N/A src.setRGB(i,2,i << 16);
0N/A }
0N/A
0N/A ColorSpace srcColorSpace = src.getColorModel().getColorSpace();
0N/A
0N/A ColorConvertOp op = new ColorConvertOp(srcColorSpace, srcColorSpace,
0N/A null);
0N/A op.filter(src, dst);
0N/A
0N/A int errCount = 0;
0N/A for (int i = 0; i < src.getWidth(); i++) {
0N/A for (int j = 0; j < src.getHeight(); j++) {
0N/A int scol = src.getRGB(i,j);
0N/A int dcol = dst.getRGB(i,j);
0N/A if (scol != dcol) {
0N/A System.err.println("(" + i + "," + j + ") : " +
0N/A Integer.toHexString(scol) + "!=" +
0N/A Integer.toHexString(dcol));
0N/A errCount++;
0N/A }
0N/A }
0N/A }
0N/A
0N/A if (errCount > 0) {
0N/A throw new RuntimeException(errCount + " pixels are changed by " +
0N/A "transform between the same ICC color " +
0N/A "spaces");
0N/A }
0N/A }
0N/A}