1 /*
2 * Copyright (c) 2014, 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 import java.awt.AlphaComposite;
25 import java.awt.Color;
26 import java.awt.Graphics2D;
27 import java.awt.GraphicsConfiguration;
28 import java.awt.GraphicsDevice;
29 import java.awt.GraphicsEnvironment;
30 import java.awt.RenderingHints;
31 import java.awt.image.BufferedImage;
32 import java.awt.image.DataBuffer;
33 import java.awt.image.DataBufferByte;
34 import java.awt.image.DataBufferInt;
35 import java.awt.image.DataBufferShort;
36 import java.awt.image.VolatileImage;
37
38 import static java.awt.Transparency.TRANSLUCENT;
39
40 /**
41 * @test
42 * @bug 8062164
43 * @summary We should get correct alpha, when we draw to/from VolatileImage and
44 * bicubic interpolation is enabled
45 * @author Sergey Bylokhov
46 */
47 public final class IncorrectAlphaConversionBicubic {
48
49 private static final Color RGB = new Color(200, 255, 7, 123);
50 private static final int SIZE = 100;
51
52 public static void main(final String[] args) {
53 final GraphicsEnvironment ge =
54 GraphicsEnvironment.getLocalGraphicsEnvironment();
55 final GraphicsDevice gd = ge.getDefaultScreenDevice();
56 final GraphicsConfiguration gc = gd.getDefaultConfiguration();
57 final VolatileImage vi =
58 gc.createCompatibleVolatileImage(SIZE, SIZE, TRANSLUCENT);
59 final BufferedImage bi = makeUnmanagedBI(gc, TRANSLUCENT);
60 final int expected = bi.getRGB(2, 2);
61
|
1 /*
2 * Copyright (c) 2014, 2016, 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 import java.awt.AlphaComposite;
25 import java.awt.Color;
26 import java.awt.Graphics2D;
27 import java.awt.GraphicsConfiguration;
28 import java.awt.GraphicsDevice;
29 import java.awt.GraphicsEnvironment;
30 import java.awt.RenderingHints;
31 import java.awt.image.BufferedImage;
32 import java.awt.image.DataBuffer;
33 import java.awt.image.DataBufferByte;
34 import java.awt.image.DataBufferInt;
35 import java.awt.image.DataBufferShort;
36 import java.awt.image.VolatileImage;
37
38 import static java.awt.Transparency.TRANSLUCENT;
39
40 /**
41 * @test
42 * @key headful
43 * @bug 8062164
44 * @summary We should get correct alpha, when we draw to/from VolatileImage and
45 * bicubic interpolation is enabled
46 * @author Sergey Bylokhov
47 */
48 public final class IncorrectAlphaConversionBicubic {
49
50 private static final Color RGB = new Color(200, 255, 7, 123);
51 private static final int SIZE = 100;
52
53 public static void main(final String[] args) {
54 final GraphicsEnvironment ge =
55 GraphicsEnvironment.getLocalGraphicsEnvironment();
56 final GraphicsDevice gd = ge.getDefaultScreenDevice();
57 final GraphicsConfiguration gc = gd.getDefaultConfiguration();
58 final VolatileImage vi =
59 gc.createCompatibleVolatileImage(SIZE, SIZE, TRANSLUCENT);
60 final BufferedImage bi = makeUnmanagedBI(gc, TRANSLUCENT);
61 final int expected = bi.getRGB(2, 2);
62
|