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 */
26 import java.awt.Graphics2D;
27 import java.awt.GraphicsConfiguration;
28 import java.awt.GraphicsEnvironment;
29 import java.awt.Image;
30 import java.awt.image.BufferedImage;
31 import java.awt.image.DataBuffer;
32 import java.awt.image.DataBufferByte;
33 import java.awt.image.DataBufferInt;
34 import java.awt.image.DataBufferShort;
35 import java.awt.image.VolatileImage;
36 import java.io.File;
37 import java.io.IOException;
38
39 import javax.imageio.ImageIO;
40
41 import static java.awt.Transparency.*;
42 import static java.awt.image.BufferedImage.*;
43
44 /**
45 * @test
46 * @bug 8029253
47 * @summary Tests asymmetric source offsets when unmanaged image is drawn to VI.
48 * Results of the blit to compatibleImage are used for comparison.
49 * @author Sergey Bylokhov
50 */
51 public final class IncorrectUnmanagedImageSourceOffset {
52
53 private static final int[] TYPES = {TYPE_INT_RGB, TYPE_INT_ARGB,
54 TYPE_INT_ARGB_PRE, TYPE_INT_BGR,
55 TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR,
56 TYPE_4BYTE_ABGR_PRE,
57 /*TYPE_USHORT_565_RGB,
58 TYPE_USHORT_555_RGB, TYPE_BYTE_GRAY,
59 TYPE_USHORT_GRAY,*/ TYPE_BYTE_BINARY,
60 TYPE_BYTE_INDEXED};
61 private static final int[] TRANSPARENCIES = {OPAQUE, BITMASK, TRANSLUCENT};
62
63 public static void main(final String[] args) throws IOException {
64 for (final int viType : TRANSPARENCIES) {
65 for (final int biType : TYPES) {
|
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 */
26 import java.awt.Graphics2D;
27 import java.awt.GraphicsConfiguration;
28 import java.awt.GraphicsEnvironment;
29 import java.awt.Image;
30 import java.awt.image.BufferedImage;
31 import java.awt.image.DataBuffer;
32 import java.awt.image.DataBufferByte;
33 import java.awt.image.DataBufferInt;
34 import java.awt.image.DataBufferShort;
35 import java.awt.image.VolatileImage;
36 import java.io.File;
37 import java.io.IOException;
38
39 import javax.imageio.ImageIO;
40
41 import static java.awt.Transparency.*;
42 import static java.awt.image.BufferedImage.*;
43
44 /**
45 * @test
46 * @key headful
47 * @bug 8029253
48 * @summary Tests asymmetric source offsets when unmanaged image is drawn to VI.
49 * Results of the blit to compatibleImage are used for comparison.
50 * @author Sergey Bylokhov
51 */
52 public final class IncorrectUnmanagedImageSourceOffset {
53
54 private static final int[] TYPES = {TYPE_INT_RGB, TYPE_INT_ARGB,
55 TYPE_INT_ARGB_PRE, TYPE_INT_BGR,
56 TYPE_3BYTE_BGR, TYPE_4BYTE_ABGR,
57 TYPE_4BYTE_ABGR_PRE,
58 /*TYPE_USHORT_565_RGB,
59 TYPE_USHORT_555_RGB, TYPE_BYTE_GRAY,
60 TYPE_USHORT_GRAY,*/ TYPE_BYTE_BINARY,
61 TYPE_BYTE_INDEXED};
62 private static final int[] TRANSPARENCIES = {OPAQUE, BITMASK, TRANSLUCENT};
63
64 public static void main(final String[] args) throws IOException {
65 for (final int viType : TRANSPARENCIES) {
66 for (final int biType : TYPES) {
|