< prev index next >
test/jdk/java/awt/Graphics/DrawImageBG/SystemBgColorTest.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 26,37 ****
* @bug 4614845
* @summary Test drawImage(bgcolor) gets correct RGB from SystemColor objects.
* @run main SystemBgColorTest
*/
! import java.awt.*;
! import java.awt.image.*;
public class SystemBgColorTest {
public static final int TESTW = 10;
public static final int TESTH = 10;
--- 26,43 ----
* @bug 4614845
* @summary Test drawImage(bgcolor) gets correct RGB from SystemColor objects.
* @run main SystemBgColorTest
*/
! import java.awt.AlphaComposite;
! import java.awt.Color;
! import java.awt.Graphics2D;
! import java.awt.Image;
! import java.awt.SystemColor;
! import java.awt.image.BufferedImage;
! import java.awt.image.DataBuffer;
! import java.awt.image.IndexColorModel;
public class SystemBgColorTest {
public static final int TESTW = 10;
public static final int TESTH = 10;
*** 107,120 ****
test(src, dst, systemColorObjects[i]);
}
}
public static void test(Image src, BufferedImage dst, Color bg) {
! Graphics g = dst.getGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, TESTW, TESTH);
g.drawImage(src, 0, 0, bg, null);
! if (dst.getRGB(0, 0) != bg.getRGB()) {
! error("bad bg pixel for: "+bg);
}
}
}
--- 113,134 ----
test(src, dst, systemColorObjects[i]);
}
}
public static void test(Image src, BufferedImage dst, Color bg) {
! Graphics2D g = (Graphics2D) dst.getGraphics();
! g.setComposite(AlphaComposite.Src);
g.setColor(Color.white);
g.fillRect(0, 0, TESTW, TESTH);
g.drawImage(src, 0, 0, bg, null);
! int dstRGB = dst.getRGB(0, 0);
! int bgRGB = bg.getRGB();
! if (!dst.getColorModel().hasAlpha()) {
! bgRGB |= 0xFF000000;
! }
! if (dstRGB != bgRGB) {
! System.err.println("Actual: " + Integer.toHexString(dstRGB));
! System.err.println("Expected: " + Integer.toHexString(bgRGB));
! error("bad bg pixel for: " + bg);
}
}
}
\ No newline at end of file
< prev index next >