1 /*
2 * Copyright (c) 2015, 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 */
36 import java.util.Locale;
37 import java.util.Set;
38 import javax.imageio.IIOImage;
39 import javax.imageio.ImageIO;
40 import javax.imageio.ImageWriteParam;
41 import javax.imageio.ImageWriter;
42 import javax.imageio.stream.ImageOutputStream;
43
44 /**
45 * @test @bug 6488522
46 * @summary Check the compression support in imageio ImageWriters
47 * @run main ImageWriterCompressionTest
48 */
49 public class ImageWriterCompressionTest {
50
51 // ignore jpg (fail):
52 // Caused by: javax.imageio.IIOException: Invalid argument to native writeImage
53 private static final Set<String> IGNORE_FILE_SUFFIXES
54 = new HashSet<String>(Arrays.asList(new String[] {
55 "bmp", "gif",
56 "jpg", "jpeg",
57 // "tif", "tiff"
58 } ));
59
60 public static void main(String[] args) {
61 Locale.setDefault(Locale.US);
62
63 final BufferedImage image
64 = new BufferedImage(512, 512, BufferedImage.TYPE_INT_ARGB);
65
66 final Graphics2D g2d = image.createGraphics();
67 try {
68 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
69 RenderingHints.VALUE_ANTIALIAS_ON);
70 g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
71 RenderingHints.VALUE_RENDER_QUALITY);
72 g2d.scale(2.0, 2.0);
73
74 g2d.setColor(Color.red);
75 g2d.draw(new Rectangle2D.Float(10, 10, 100, 100));
76 g2d.setColor(Color.blue);
77 g2d.fill(new Rectangle2D.Float(12, 12, 98, 98));
|
1 /*
2 * Copyright (c) 2015, 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 */
36 import java.util.Locale;
37 import java.util.Set;
38 import javax.imageio.IIOImage;
39 import javax.imageio.ImageIO;
40 import javax.imageio.ImageWriteParam;
41 import javax.imageio.ImageWriter;
42 import javax.imageio.stream.ImageOutputStream;
43
44 /**
45 * @test @bug 6488522
46 * @summary Check the compression support in imageio ImageWriters
47 * @run main ImageWriterCompressionTest
48 */
49 public class ImageWriterCompressionTest {
50
51 // ignore jpg (fail):
52 // Caused by: javax.imageio.IIOException: Invalid argument to native writeImage
53 private static final Set<String> IGNORE_FILE_SUFFIXES
54 = new HashSet<String>(Arrays.asList(new String[] {
55 "bmp", "gif",
56 "jpg", "jpeg"
57 } ));
58
59 public static void main(String[] args) {
60 Locale.setDefault(Locale.US);
61
62 final BufferedImage image
63 = new BufferedImage(512, 512, BufferedImage.TYPE_INT_ARGB);
64
65 final Graphics2D g2d = image.createGraphics();
66 try {
67 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
68 RenderingHints.VALUE_ANTIALIAS_ON);
69 g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
70 RenderingHints.VALUE_RENDER_QUALITY);
71 g2d.scale(2.0, 2.0);
72
73 g2d.setColor(Color.red);
74 g2d.draw(new Rectangle2D.Float(10, 10, 100, 100));
75 g2d.setColor(Color.blue);
76 g2d.fill(new Rectangle2D.Float(12, 12, 98, 98));
|