--- /dev/null 2017-05-22 14:23:40.000000000 -0700 +++ new/test/javax/imageio/plugins/wbmp/WBMPPluginTest.java 2017-05-22 14:23:40.000000000 -0700 @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2003, 2017, 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. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4641872 + * @summary Tests writing and reading abilities of WBMP plugin + */ + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.Raster; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Iterator; + +import javax.imageio.IIOException; +import javax.imageio.IIOImage; +import javax.imageio.ImageIO; +import javax.imageio.ImageReader; +import javax.imageio.ImageTypeSpecifier; +import javax.imageio.ImageWriteParam; +import javax.imageio.ImageWriter; +import javax.imageio.metadata.IIOMetadata; + +public class WBMPPluginTest { + + private static final int[] types = { + BufferedImage.TYPE_INT_RGB, // = 1; + BufferedImage.TYPE_INT_ARGB, // = 2; + BufferedImage.TYPE_INT_ARGB_PRE, // = 3; + BufferedImage.TYPE_INT_BGR, // = 4; + BufferedImage.TYPE_3BYTE_BGR, // = 5; + BufferedImage.TYPE_4BYTE_ABGR, // = 6; + BufferedImage.TYPE_4BYTE_ABGR_PRE, // 7 + BufferedImage.TYPE_USHORT_565_RGB, // 8 + BufferedImage.TYPE_USHORT_555_RGB, // 9 + BufferedImage.TYPE_BYTE_GRAY, // 10 + BufferedImage.TYPE_USHORT_GRAY, //11 + BufferedImage.TYPE_BYTE_BINARY, //12 + BufferedImage.TYPE_BYTE_INDEXED //13 + }; + + private static String format = "WBMP"; + + private static ImageReader ir = null; + private static ImageWriter iw = null; + private BufferedImage img; + private ImageWriteParam param; + private ByteArrayOutputStream baos; + + private static void init() { + + Iterator i = ImageIO.getImageWritersByFormatName(format); + if (!i.hasNext()) { + throw new RuntimeException("No available ImageWrites for "+format+" format!"); + } + iw = (ImageWriter)i.next(); + + i = ImageIO.getImageReadersByFormatName(format); + if (!i.hasNext()) { + throw new RuntimeException("No available ImageReaders for " +format+" format!"); + } + + ir = (ImageReader)i.next(); + } + + public static void main(String[] args) { + if (args.length > 0) { + format = args[0]; + System.out.println("Test format " + format); + } + + init(); + ImageIO.setUseCache(false); + + for (int i=0; i