< prev index next >

test/javax/imageio/plugins/shared/BitDepth.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2007, 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, 2016, 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.
*** 21,35 **** * questions. */ /** * @test ! * @bug 4413109 4418221 6607198 * @run main BitDepth ! * @summary Checks that the PNG and JPEG writers can handle various ! * BufferedImage types. An optional list of arguments may be used to ! * test a different format writer or writers. */ import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; --- 21,35 ---- * questions. */ /** * @test ! * @bug 4413109 4418221 6607198 8147448 * @run main BitDepth ! * @summary Checks that ImageIO writers for standard formats can handle ! * various BufferedImage RGB types. An optional list of arguments ! * may be used to test the writers for a different list of formats. */ import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage;
*** 79,103 **** private static final int[] biRGBTypes = { BufferedImage.TYPE_INT_RGB, BufferedImage.TYPE_INT_BGR, BufferedImage.TYPE_3BYTE_BGR, BufferedImage.TYPE_USHORT_565_RGB, ! BufferedImage.TYPE_USHORT_555_RGB ! }; ! ! private static final int[] biRGBATypes = { BufferedImage.TYPE_INT_ARGB, BufferedImage.TYPE_INT_ARGB_PRE, BufferedImage.TYPE_4BYTE_ABGR, BufferedImage.TYPE_4BYTE_ABGR_PRE }; ! private static final int[] biGrayTypes = { ! BufferedImage.TYPE_BYTE_GRAY, ! BufferedImage.TYPE_USHORT_GRAY, ! BufferedImage.TYPE_BYTE_BINARY ! }; private static final String[] biTypeNames = { "CUSTOM", "INT_RGB", "INT_ARGB", --- 79,101 ---- private static final int[] biRGBTypes = { BufferedImage.TYPE_INT_RGB, BufferedImage.TYPE_INT_BGR, BufferedImage.TYPE_3BYTE_BGR, BufferedImage.TYPE_USHORT_565_RGB, ! BufferedImage.TYPE_USHORT_555_RGB, BufferedImage.TYPE_INT_ARGB, BufferedImage.TYPE_INT_ARGB_PRE, BufferedImage.TYPE_4BYTE_ABGR, BufferedImage.TYPE_4BYTE_ABGR_PRE }; ! //private static final int[] biGrayTypes = { ! // BufferedImage.TYPE_BYTE_GRAY, ! // BufferedImage.TYPE_USHORT_GRAY, ! // BufferedImage.TYPE_BYTE_BINARY ! //}; ! private static final String[] biTypeNames = { "CUSTOM", "INT_RGB", "INT_ARGB",
*** 114,124 **** "BYTE_INDEXED" }; private int width = 80; private int height = 80; ! private String[] format = { "png", "jpeg" }; public BitDepth(String[] args) throws IOException { if (args.length > 0) { format = args; } --- 112,122 ---- "BYTE_INDEXED" }; private int width = 80; private int height = 80; ! private String[] format = { "png", "jpeg", "tif", "bmp", "gif" }; public BitDepth(String[] args) throws IOException { if (args.length > 0) { format = args; }
*** 127,150 **** --- 125,168 ---- testFormat(format[i]); } } private void testFormat(String format) throws IOException { + boolean allOK = true; for (int i = 0; i < biRGBTypes.length; i++) { + int type = biRGBTypes[i]; + + + // TODO: remove the following 'if' block after the 8147448 fix + if ( format.toLowerCase().equals("bmp") && ( + (type == BufferedImage.TYPE_INT_ARGB ) || + (type == BufferedImage.TYPE_INT_ARGB_PRE ) || + (type == BufferedImage.TYPE_4BYTE_ABGR ) || + (type == BufferedImage.TYPE_4BYTE_ABGR_PRE ))) { + + System.err.println("cannot use " + biTypeNames[type] + + " for bmp because of JDK-8147448.\t" + + " please update the test after fix of this bug!"); + continue; + } + + System.out.println("Testing " + format + " writer for type " + biTypeNames[type]); File f = testWriteRGB(format, type); boolean ok = testReadRGB(f); if (ok) { f.delete(); } allOK = allOK && ok; } + + if (format.equals("png")) { System.out.println("Testing png writer for black stripe"); boolean ok = testPNGByteBinary(); allOK = allOK && ok; }
*** 152,163 **** if (!allOK) { throw new RuntimeException("Test failed"); } } ! private File testWriteRGB(String format, int type) ! throws IOException { BufferedImage bi = new BufferedImage(width, height, type); Graphics2D g = bi.createGraphics(); Color white = new Color(255, 255, 255); Color red = new Color(255, 0, 0); --- 170,181 ---- if (!allOK) { throw new RuntimeException("Test failed"); } } ! private File testWriteRGB(String format, int type) throws IOException { ! BufferedImage bi = new BufferedImage(width, height, type); Graphics2D g = bi.createGraphics(); Color white = new Color(255, 255, 255); Color red = new Color(255, 0, 0);
< prev index next >