Java Code Examples for javax.imageio.spi.IIORegistry#getDefaultInstance()
The following examples show how to use
javax.imageio.spi.IIORegistry#getDefaultInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SnapApp.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
private static void initImageIO() { // todo - actually this should be done in the activator of ceres-jai which does not exist yet Lookup.Result<ModuleInfo> moduleInfos = Lookup.getDefault().lookupResult(ModuleInfo.class); String ceresJaiCodeName = "org.esa.snap.ceres.jai"; Optional<? extends ModuleInfo> info = moduleInfos.allInstances().stream().filter( moduleInfo -> ceresJaiCodeName.equals(moduleInfo.getCodeName())).findFirst(); if (info.isPresent()) { ClassLoader classLoader = info.get().getClassLoader(); IIORegistry iioRegistry = IIORegistry.getDefaultInstance(); iioRegistry.registerServiceProviders(IIORegistry.lookupProviders(ImageReaderSpi.class, classLoader)); iioRegistry.registerServiceProviders(IIORegistry.lookupProviders(ImageWriterSpi.class, classLoader)); } else { LOG.warning(String.format("Module '%s' not found. Not able to load image-IO services.", ceresJaiCodeName)); } }
Example 2
Source File: ImageValue.java From MyBox with Apache License 2.0 | 6 votes |
public static void registrySupportedImageFormats() { IIORegistry registry = IIORegistry.getDefaultInstance(); // registry.registerServiceProvider(new TIFFImageWriterSpi()); // registry.registerServiceProvider(new TIFFImageReaderSpi()); // registry.registerServiceProvider(new BMPImageWriterSpi()); // registry.registerServiceProvider(new BMPImageReaderSpi()); // registry.registerServiceProvider(new GIFImageWriterSpi()); // registry.registerServiceProvider(new WBMPImageWriterSpi()); // registry.registerServiceProvider(new WBMPImageReaderSpi()); registry.registerServiceProvider(new RawImageWriterSpi()); registry.registerServiceProvider(new RawImageReaderSpi()); registry.registerServiceProvider(new PCXImageWriterSpi()); registry.registerServiceProvider(new PCXImageReaderSpi()); registry.registerServiceProvider(new PNMImageWriterSpi()); registry.registerServiceProvider(new PNMImageReaderSpi()); // registry.registerServiceProvider(new J2KImageWriterSpi()); // registry.registerServiceProvider(new J2KImageReaderSpi()); // String readFormats[] = ImageIO.getReaderFormatNames(); // String writeFormats[] = ImageIO.getWriterFormatNames(); // logger.info("Readers:" + Arrays.asList(readFormats)); // logger.info("Writers:" + Arrays.asList(writeFormats)); //Readers:[JPG, JPEG 2000, tiff, bmp, PCX, gif, WBMP, PNG, RAW, JPEG, PNM, tif, TIFF, wbmp, jpeg, jpg, JPEG2000, BMP, pcx, GIF, png, raw, pnm, TIF, jpeg2000, jpeg 2000] //Writers:[JPEG 2000, JPG, tiff, bmp, PCX, gif, WBMP, PNG, RAW, JPEG, PNM, tif, TIFF, wbmp, jpeg, jpg, JPEG2000, BMP, pcx, GIF, png, raw, pnm, TIF, jpeg2000, jpeg 2000] }
Example 3
Source File: OrderingTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public OrderingTest() { ServiceRegistry reg = IIORegistry.getDefaultInstance(); ImageReaderSpi gifSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.gif.GIFImageReaderSpi.class); ImageReaderSpi pngSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.png.PNGImageReaderSpi.class); boolean ordered = reg.setOrdering(ImageReaderSpi.class, gifSpi, pngSpi); ordered = reg.setOrdering(ImageReaderSpi.class, pngSpi, gifSpi); boolean unordered = reg.unsetOrdering(ImageReaderSpi.class, gifSpi, pngSpi); boolean unordered1 = reg.unsetOrdering(ImageReaderSpi.class, gifSpi, pngSpi); if (unordered1) { throw new RuntimeException("FAIL: Ordering 2 spi objects in the " + "reverse direction does not remove the previous ordering " + "set between the spi objects and hence unsetOrdering() " + "returns true for the same spi objects when called consecutively"); } else { System.out.println("PASS"); } }
Example 4
Source File: OutputImageTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void initIIOWriteFormats() { List spis = new ArrayList(); List shortNames = new ArrayList(); ImageIO.scanForPlugins(); IIORegistry registry = IIORegistry.getDefaultInstance(); java.util.Iterator writerspis = registry.getServiceProviders(ImageWriterSpi.class, false); while (writerspis.hasNext()) { // REMIND: there could be more than one non-core plugin for // a particular format, as is the case for JPEG2000 in the JAI // IIO Tools package, so we should support that somehow ImageWriterSpi spi = (ImageWriterSpi)writerspis.next(); String klass = spi.getClass().getName(); String format = spi.getFormatNames()[0].toLowerCase(); String suffix = spi.getFileSuffixes()[0].toLowerCase(); if (suffix == null || suffix.equals("")) { suffix = format; } String shortName; if (klass.startsWith("com.sun.imageio.plugins")) { shortName = "core-" + suffix; } else { shortName = "ext-" + suffix; } spis.add(spi); shortNames.add(shortName); } imageioWriterSpis = new ImageWriterSpi[spis.size()]; imageioWriterSpis = (ImageWriterSpi[])spis.toArray(imageioWriterSpis); imageioWriteFormatShortNames = new String[shortNames.size()]; imageioWriteFormatShortNames = (String[])shortNames.toArray(imageioWriteFormatShortNames); }
Example 5
Source File: InputImageTests.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static void initIIOReadFormats() { List spis = new ArrayList(); List shortNames = new ArrayList(); ImageIO.scanForPlugins(); IIORegistry registry = IIORegistry.getDefaultInstance(); java.util.Iterator readerspis = registry.getServiceProviders(ImageReaderSpi.class, false); while (readerspis.hasNext()) { // REMIND: there could be more than one non-core plugin for // a particular format, as is the case for JPEG2000 in the JAI // IIO Tools package, so we should support that somehow ImageReaderSpi spi = (ImageReaderSpi)readerspis.next(); String klass = spi.getClass().getName(); String format = spi.getFormatNames()[0].toLowerCase(); String suffix = spi.getFileSuffixes()[0].toLowerCase(); if (suffix == null || suffix.equals("")) { suffix = format; } String shortName; if (klass.startsWith("com.sun.imageio.plugins")) { shortName = "core-" + suffix; } else { shortName = "ext-" + suffix; } spis.add(spi); shortNames.add(shortName); } imageioReaderSpis = new ImageReaderSpi[spis.size()]; imageioReaderSpis = (ImageReaderSpi[])spis.toArray(imageioReaderSpis); imageioReadFormatShortNames = new String[shortNames.size()]; imageioReadFormatShortNames = (String[])shortNames.toArray(imageioReadFormatShortNames); }
Example 6
Source File: WriteAfterAbort.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(final String[] args) throws IOException { final IIORegistry registry = IIORegistry.getDefaultInstance(); final Iterator<ImageWriterSpi> iter = registry.getServiceProviders( ImageWriterSpi.class, provider -> true, true); // Validates all supported ImageWriters while (iter.hasNext()) { final WriteAfterAbort writeAfterAbort = new WriteAfterAbort(); final ImageWriter writer = iter.next().createWriterInstance(); System.out.println("ImageWriter = " + writer); writeAfterAbort.test(writer); } System.out.println("Test passed"); }
Example 7
Source File: InputImageTests.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void initIIOReadFormats() { List spis = new ArrayList(); List shortNames = new ArrayList(); ImageIO.scanForPlugins(); IIORegistry registry = IIORegistry.getDefaultInstance(); java.util.Iterator readerspis = registry.getServiceProviders(ImageReaderSpi.class, false); while (readerspis.hasNext()) { // REMIND: there could be more than one non-core plugin for // a particular format, as is the case for JPEG2000 in the JAI // IIO Tools package, so we should support that somehow ImageReaderSpi spi = (ImageReaderSpi)readerspis.next(); String klass = spi.getClass().getName(); String format = spi.getFormatNames()[0].toLowerCase(); String suffix = spi.getFileSuffixes()[0].toLowerCase(); if (suffix == null || suffix.equals("")) { suffix = format; } String shortName; if (klass.startsWith("com.sun.imageio.plugins")) { shortName = "core-" + suffix; } else { shortName = "ext-" + suffix; } spis.add(spi); shortNames.add(shortName); } imageioReaderSpis = new ImageReaderSpi[spis.size()]; imageioReaderSpis = (ImageReaderSpi[])spis.toArray(imageioReaderSpis); imageioReadFormatShortNames = new String[shortNames.size()]; imageioReadFormatShortNames = (String[])shortNames.toArray(imageioReadFormatShortNames); }
Example 8
Source File: OutputImageTests.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static void initIIOWriteFormats() { List spis = new ArrayList(); List shortNames = new ArrayList(); ImageIO.scanForPlugins(); IIORegistry registry = IIORegistry.getDefaultInstance(); java.util.Iterator writerspis = registry.getServiceProviders(ImageWriterSpi.class, false); while (writerspis.hasNext()) { // REMIND: there could be more than one non-core plugin for // a particular format, as is the case for JPEG2000 in the JAI // IIO Tools package, so we should support that somehow ImageWriterSpi spi = (ImageWriterSpi)writerspis.next(); String klass = spi.getClass().getName(); String format = spi.getFormatNames()[0].toLowerCase(); String suffix = spi.getFileSuffixes()[0].toLowerCase(); if (suffix == null || suffix.equals("")) { suffix = format; } String shortName; if (klass.startsWith("com.sun.imageio.plugins")) { shortName = "core-" + suffix; } else { shortName = "ext-" + suffix; } spis.add(spi); shortNames.add(shortName); } imageioWriterSpis = new ImageWriterSpi[spis.size()]; imageioWriterSpis = (ImageWriterSpi[])spis.toArray(imageioWriterSpis); imageioWriteFormatShortNames = new String[shortNames.size()]; imageioWriteFormatShortNames = (String[])shortNames.toArray(imageioWriteFormatShortNames); }
Example 9
Source File: InputImageTests.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static void initIIOReadFormats() { List spis = new ArrayList(); List shortNames = new ArrayList(); ImageIO.scanForPlugins(); IIORegistry registry = IIORegistry.getDefaultInstance(); java.util.Iterator readerspis = registry.getServiceProviders(ImageReaderSpi.class, false); while (readerspis.hasNext()) { // REMIND: there could be more than one non-core plugin for // a particular format, as is the case for JPEG2000 in the JAI // IIO Tools package, so we should support that somehow ImageReaderSpi spi = (ImageReaderSpi)readerspis.next(); String klass = spi.getClass().getName(); String format = spi.getFormatNames()[0].toLowerCase(); String suffix = spi.getFileSuffixes()[0].toLowerCase(); if (suffix == null || suffix.equals("")) { suffix = format; } String shortName; if (klass.startsWith("com.sun.imageio.plugins")) { shortName = "core-" + suffix; } else { shortName = "ext-" + suffix; } spis.add(spi); shortNames.add(shortName); } imageioReaderSpis = new ImageReaderSpi[spis.size()]; imageioReaderSpis = (ImageReaderSpi[])spis.toArray(imageioReaderSpis); imageioReadFormatShortNames = new String[shortNames.size()]; imageioReadFormatShortNames = (String[])shortNames.toArray(imageioReadFormatShortNames); }
Example 10
Source File: OutputImageTests.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void initIIOWriteFormats() { List spis = new ArrayList(); List shortNames = new ArrayList(); ImageIO.scanForPlugins(); IIORegistry registry = IIORegistry.getDefaultInstance(); java.util.Iterator writerspis = registry.getServiceProviders(ImageWriterSpi.class, false); while (writerspis.hasNext()) { // REMIND: there could be more than one non-core plugin for // a particular format, as is the case for JPEG2000 in the JAI // IIO Tools package, so we should support that somehow ImageWriterSpi spi = (ImageWriterSpi)writerspis.next(); String klass = spi.getClass().getName(); String format = spi.getFormatNames()[0].toLowerCase(); String suffix = spi.getFileSuffixes()[0].toLowerCase(); if (suffix == null || suffix.equals("")) { suffix = format; } String shortName; if (klass.startsWith("com.sun.imageio.plugins")) { shortName = "core-" + suffix; } else { shortName = "ext-" + suffix; } spis.add(spi); shortNames.add(shortName); } imageioWriterSpis = new ImageWriterSpi[spis.size()]; imageioWriterSpis = (ImageWriterSpi[])spis.toArray(imageioWriterSpis); imageioWriteFormatShortNames = new String[shortNames.size()]; imageioWriteFormatShortNames = (String[])shortNames.toArray(imageioWriteFormatShortNames); }
Example 11
Source File: CanWriteSequence.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(final String[] args) throws Exception { final IIORegistry registry = IIORegistry.getDefaultInstance(); final Iterator<ImageWriterSpi> iter = registry.getServiceProviders(ImageWriterSpi.class, provider -> true, true); // Validates all supported ImageWriters while (iter.hasNext()) { final ImageWriter writer = iter.next().createWriterInstance(); System.out.println("ImageWriter = " + writer); test(writer); } System.out.println("Test passed"); }
Example 12
Source File: InputImageTests.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void initIIOReadFormats() { List spis = new ArrayList(); List shortNames = new ArrayList(); ImageIO.scanForPlugins(); IIORegistry registry = IIORegistry.getDefaultInstance(); java.util.Iterator readerspis = registry.getServiceProviders(ImageReaderSpi.class, false); while (readerspis.hasNext()) { // REMIND: there could be more than one non-core plugin for // a particular format, as is the case for JPEG2000 in the JAI // IIO Tools package, so we should support that somehow ImageReaderSpi spi = (ImageReaderSpi)readerspis.next(); String klass = spi.getClass().getName(); String format = spi.getFormatNames()[0].toLowerCase(); String suffix = spi.getFileSuffixes()[0].toLowerCase(); if (suffix == null || suffix.equals("")) { suffix = format; } String shortName; if (klass.startsWith("com.sun.imageio.plugins")) { shortName = "core-" + suffix; } else { shortName = "ext-" + suffix; } spis.add(spi); shortNames.add(shortName); } imageioReaderSpis = new ImageReaderSpi[spis.size()]; imageioReaderSpis = (ImageReaderSpi[])spis.toArray(imageioReaderSpis); imageioReadFormatShortNames = new String[shortNames.size()]; imageioReadFormatShortNames = (String[])shortNames.toArray(imageioReadFormatShortNames); }
Example 13
Source File: InputImageTests.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void initIIOReadFormats() { List spis = new ArrayList(); List shortNames = new ArrayList(); ImageIO.scanForPlugins(); IIORegistry registry = IIORegistry.getDefaultInstance(); java.util.Iterator readerspis = registry.getServiceProviders(ImageReaderSpi.class, false); while (readerspis.hasNext()) { // REMIND: there could be more than one non-core plugin for // a particular format, as is the case for JPEG2000 in the JAI // IIO Tools package, so we should support that somehow ImageReaderSpi spi = (ImageReaderSpi)readerspis.next(); String klass = spi.getClass().getName(); String format = spi.getFormatNames()[0].toLowerCase(); String suffix = spi.getFileSuffixes()[0].toLowerCase(); if (suffix == null || suffix.equals("")) { suffix = format; } String shortName; if (klass.startsWith("com.sun.imageio.plugins")) { shortName = "core-" + suffix; } else { shortName = "ext-" + suffix; } spis.add(spi); shortNames.add(shortName); } imageioReaderSpis = new ImageReaderSpi[spis.size()]; imageioReaderSpis = (ImageReaderSpi[])spis.toArray(imageioReaderSpis); imageioReadFormatShortNames = new String[shortNames.size()]; imageioReadFormatShortNames = (String[])shortNames.toArray(imageioReadFormatShortNames); }
Example 14
Source File: OutputImageTests.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void initIIOWriteFormats() { List spis = new ArrayList(); List shortNames = new ArrayList(); ImageIO.scanForPlugins(); IIORegistry registry = IIORegistry.getDefaultInstance(); java.util.Iterator writerspis = registry.getServiceProviders(ImageWriterSpi.class, false); while (writerspis.hasNext()) { // REMIND: there could be more than one non-core plugin for // a particular format, as is the case for JPEG2000 in the JAI // IIO Tools package, so we should support that somehow ImageWriterSpi spi = (ImageWriterSpi)writerspis.next(); String klass = spi.getClass().getName(); String format = spi.getFormatNames()[0].toLowerCase(); String suffix = spi.getFileSuffixes()[0].toLowerCase(); if (suffix == null || suffix.equals("")) { suffix = format; } String shortName; if (klass.startsWith("com.sun.imageio.plugins")) { shortName = "core-" + suffix; } else { shortName = "ext-" + suffix; } spis.add(spi); shortNames.add(shortName); } imageioWriterSpis = new ImageWriterSpi[spis.size()]; imageioWriterSpis = (ImageWriterSpi[])spis.toArray(imageioWriterSpis); imageioWriteFormatShortNames = new String[shortNames.size()]; imageioWriteFormatShortNames = (String[])shortNames.toArray(imageioWriteFormatShortNames); }
Example 15
Source File: WriteAfterAbort.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(final String[] args) throws IOException { final IIORegistry registry = IIORegistry.getDefaultInstance(); final Iterator<ImageWriterSpi> iter = registry.getServiceProviders( ImageWriterSpi.class, provider -> true, true); // Validates all supported ImageWriters while (iter.hasNext()) { final WriteAfterAbort writeAfterAbort = new WriteAfterAbort(); final ImageWriter writer = iter.next().createWriterInstance(); System.out.println("ImageWriter = " + writer); writeAfterAbort.test(writer); } System.out.println("Test passed"); }
Example 16
Source File: CanWriteSequence.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(final String[] args) throws Exception { final IIORegistry registry = IIORegistry.getDefaultInstance(); final Iterator<ImageWriterSpi> iter = registry.getServiceProviders(ImageWriterSpi.class, provider -> true, true); // Validates all supported ImageWriters while (iter.hasNext()) { final ImageWriter writer = iter.next().createWriterInstance(); System.out.println("ImageWriter = " + writer); test(writer); } System.out.println("Test passed"); }
Example 17
Source File: OutputImageTests.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static void initIIOWriteFormats() { List spis = new ArrayList(); List shortNames = new ArrayList(); ImageIO.scanForPlugins(); IIORegistry registry = IIORegistry.getDefaultInstance(); java.util.Iterator writerspis = registry.getServiceProviders(ImageWriterSpi.class, false); while (writerspis.hasNext()) { // REMIND: there could be more than one non-core plugin for // a particular format, as is the case for JPEG2000 in the JAI // IIO Tools package, so we should support that somehow ImageWriterSpi spi = (ImageWriterSpi)writerspis.next(); String klass = spi.getClass().getName(); String format = spi.getFormatNames()[0].toLowerCase(); String suffix = spi.getFileSuffixes()[0].toLowerCase(); if (suffix == null || suffix.equals("")) { suffix = format; } String shortName; if (klass.startsWith("com.sun.imageio.plugins")) { shortName = "core-" + suffix; } else { shortName = "ext-" + suffix; } spis.add(spi); shortNames.add(shortName); } imageioWriterSpis = new ImageWriterSpi[spis.size()]; imageioWriterSpis = (ImageWriterSpi[])spis.toArray(imageioWriterSpis); imageioWriteFormatShortNames = new String[shortNames.size()]; imageioWriteFormatShortNames = (String[])shortNames.toArray(imageioWriteFormatShortNames); }
Example 18
Source File: RegisteredFormatsTest.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { fmts = new Hashtable(); fmts.put("javax_imageio_jpeg_stream_1.0", Boolean.FALSE); fmts.put("javax_imageio_jpeg_image_1.0", Boolean.FALSE); fmts.put("javax_imageio_png_1.0", Boolean.FALSE); fmts.put("javax_imageio_bmp_1.0", Boolean.FALSE); fmts.put("javax_imageio_wbmp_1.0", Boolean.FALSE); fmts.put("javax_imageio_gif_stream_1.0", Boolean.FALSE); fmts.put("javax_imageio_gif_image_1.0", Boolean.FALSE); IIORegistry registry = IIORegistry.getDefaultInstance(); Iterator iter = registry.getServiceProviders(ImageReaderSpi.class, false); while(iter.hasNext()) { ImageReaderSpi spi = (ImageReaderSpi)iter.next(); String fmt_name; fmt_name = spi.getNativeStreamMetadataFormatName(); testStreamMetadataFormat(spi, fmt_name); fmt_name = spi.getNativeImageMetadataFormatName(); testImageMetadataFormat(spi, fmt_name); String[] fmt_names; fmt_names = spi.getExtraStreamMetadataFormatNames(); for (int i=0; fmt_names != null && i < fmt_names.length; i++) { testStreamMetadataFormat(spi, fmt_names[i]); } fmt_names = spi.getExtraImageMetadataFormatNames(); for (int i=0; fmt_names != null && i < fmt_names.length; i++) { testImageMetadataFormat(spi, fmt_names[i]); } } Enumeration keys = fmts.keys(); while (keys.hasMoreElements()) { String key = (String)keys.nextElement(); boolean val = ((Boolean)fmts.get(key)).booleanValue(); if (!val) { throw new RuntimeException("Test failed: format " + key + "is not registered."); } } }
Example 19
Source File: RegisteredFormatsTest.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { fmts = new Hashtable(); fmts.put("javax_imageio_jpeg_stream_1.0", Boolean.FALSE); fmts.put("javax_imageio_jpeg_image_1.0", Boolean.FALSE); fmts.put("javax_imageio_png_1.0", Boolean.FALSE); fmts.put("javax_imageio_bmp_1.0", Boolean.FALSE); fmts.put("javax_imageio_wbmp_1.0", Boolean.FALSE); fmts.put("javax_imageio_gif_stream_1.0", Boolean.FALSE); fmts.put("javax_imageio_gif_image_1.0", Boolean.FALSE); IIORegistry registry = IIORegistry.getDefaultInstance(); Iterator iter = registry.getServiceProviders(ImageReaderSpi.class, false); while(iter.hasNext()) { ImageReaderSpi spi = (ImageReaderSpi)iter.next(); String fmt_name; fmt_name = spi.getNativeStreamMetadataFormatName(); testStreamMetadataFormat(spi, fmt_name); fmt_name = spi.getNativeImageMetadataFormatName(); testImageMetadataFormat(spi, fmt_name); String[] fmt_names; fmt_names = spi.getExtraStreamMetadataFormatNames(); for (int i=0; fmt_names != null && i < fmt_names.length; i++) { testStreamMetadataFormat(spi, fmt_names[i]); } fmt_names = spi.getExtraImageMetadataFormatNames(); for (int i=0; fmt_names != null && i < fmt_names.length; i++) { testImageMetadataFormat(spi, fmt_names[i]); } } Enumeration keys = fmts.keys(); while (keys.hasMoreElements()) { String key = (String)keys.nextElement(); boolean val = ((Boolean)fmts.get(key)).booleanValue(); if (!val) { throw new RuntimeException("Test failed: format " + key + "is not registered."); } } }
Example 20
Source File: RegisteredFormatsTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { fmts = new Hashtable(); fmts.put("javax_imageio_jpeg_stream_1.0", Boolean.FALSE); fmts.put("javax_imageio_jpeg_image_1.0", Boolean.FALSE); fmts.put("javax_imageio_png_1.0", Boolean.FALSE); fmts.put("javax_imageio_bmp_1.0", Boolean.FALSE); fmts.put("javax_imageio_wbmp_1.0", Boolean.FALSE); fmts.put("javax_imageio_gif_stream_1.0", Boolean.FALSE); fmts.put("javax_imageio_gif_image_1.0", Boolean.FALSE); IIORegistry registry = IIORegistry.getDefaultInstance(); Iterator iter = registry.getServiceProviders(ImageReaderSpi.class, false); while(iter.hasNext()) { ImageReaderSpi spi = (ImageReaderSpi)iter.next(); String fmt_name; fmt_name = spi.getNativeStreamMetadataFormatName(); testStreamMetadataFormat(spi, fmt_name); fmt_name = spi.getNativeImageMetadataFormatName(); testImageMetadataFormat(spi, fmt_name); String[] fmt_names; fmt_names = spi.getExtraStreamMetadataFormatNames(); for (int i=0; fmt_names != null && i < fmt_names.length; i++) { testStreamMetadataFormat(spi, fmt_names[i]); } fmt_names = spi.getExtraImageMetadataFormatNames(); for (int i=0; fmt_names != null && i < fmt_names.length; i++) { testImageMetadataFormat(spi, fmt_names[i]); } } Enumeration keys = fmts.keys(); while (keys.hasMoreElements()) { String key = (String)keys.nextElement(); boolean val = ((Boolean)fmts.get(key)).booleanValue(); if (!val) { throw new RuntimeException("Test failed: format " + key + "is not registered."); } } }