Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/java2d/loops/Bug7049339.java
41149 views
1
/*
2
* Copyright 2011 Red Hat, Inc. All Rights Reserved.
3
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
*
6
* This code is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 2 only, as
8
* published by the Free Software Foundation.
9
*
10
* This code is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* version 2 for more details (a copy is included in the LICENSE file that
14
* accompanied this code).
15
*
16
* You should have received a copy of the GNU General Public License version
17
* 2 along with this work; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
*
20
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
* or visit www.oracle.com if you need additional information or have any
22
* questions.
23
*/
24
25
/*
26
@test
27
@bug 7049339
28
@summary Copying images with a non-rectangular clip and a custom composite
29
fails
30
@author Denis Lila <[email protected]>
31
@run main Bug7049339
32
*/
33
34
import java.awt.Composite;
35
import java.awt.CompositeContext;
36
import java.awt.Graphics2D;
37
import java.awt.RenderingHints;
38
import java.awt.Shape;
39
import java.awt.geom.Ellipse2D;
40
import java.awt.image.BufferedImage;
41
import java.awt.image.ColorModel;
42
import java.awt.image.Raster;
43
import java.awt.image.WritableRaster;
44
45
public class Bug7049339 {
46
public static void main(String[] argv) {
47
int x = 100, y = 100;
48
BufferedImage src = new BufferedImage(x, y, BufferedImage.TYPE_INT_ARGB);
49
BufferedImage dst = new BufferedImage(x, y, BufferedImage.TYPE_3BYTE_BGR);
50
51
Graphics2D dstg2d = dst.createGraphics();
52
dstg2d.setComposite(new Composite() {
53
@Override
54
public CompositeContext createContext(
55
ColorModel srcColorModel,
56
ColorModel dstColorModel,
57
RenderingHints hints)
58
{
59
return new CompositeContext() {
60
@Override
61
public void compose(Raster src, Raster dstIn,
62
WritableRaster dstOut)
63
{
64
// do nothing
65
}
66
@Override
67
public void dispose() {
68
}
69
};
70
}
71
});
72
Shape clip = new Ellipse2D.Double(x/4, y/4, x/2, y/2);
73
dstg2d.setClip(clip);
74
// This will throw a RasterFormatException if the bug is present.
75
dstg2d.drawImage(src, 0, 0, null);
76
}
77
}
78
79