Java Code Examples for javax.imageio.ImageIO#scanForPlugins()

The following examples show how to use javax.imageio.ImageIO#scanForPlugins() . 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: HelpTask.java    From extract with MIT License 6 votes vote down vote up
@Override
public Void call() throws Exception {
	ImageIO.scanForPlugins();

	final HelpFormatter formatter = new HelpFormatter();
	final Set<String> tasks = Main.taskFactory.listNames();
	final String[] imageFormats = Arrays.stream(ImageIO.getReaderFormatNames())
			.map(String::toLowerCase)
			.distinct()
			.toArray(String[]::new);

	String header = String.format("%nA cross-platform tool for distributed content-extraction " +
			"by the data team at the International Consortium of Investigative Journalists.%n%n" +
			"\033[1mCommands\033[0m%n%n %s%n%n\033[1mAdditional Image Formats\033[0m%n%n %s", String.join("\n ",
			tasks), String.join("\n ", (CharSequence[]) imageFormats));

	formatter.printHelp(String.format("\033[1mextract\033[0m [command] [options]%n" +
			"%s\033[1mextract\033[0m help%n" +
			"%s\033[1mextract\033[0m version", formatter.getSyntaxPrefix(), formatter
			.getSyntaxPrefix()), header, new org.apache.commons.cli.Options(), footer, false);
	return null;
}
 
Example 2
Source File: OutputImageTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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 3
Source File: OutputImageTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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 4
Source File: InputImageTests.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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 5
Source File: OutputImageTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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 6
Source File: InputImageTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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 7
Source File: OutputImageTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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 8
Source File: OutputImageTests.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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: OutputImageTests.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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 10
Source File: InputImageTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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 11
Source File: InputImageTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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 12
Source File: InputImageTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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: CacheWriter.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void write (String filename, boolean append) throws IOException {
    try {
        BufferedImage img;
        //Force the gif decoder to get registered
        Object o = com.sun.imageio.plugins.gif.GIFImageReader.class;
        ImageIO.scanForPlugins();
        
        img = ImageIO.read(new File(filename));
            write (img, append, filename);
            
    } catch (Exception ioe) {
        System.err.println("Could not write " + filename + " - " + ioe.getMessage());
        ioe.printStackTrace();
    }
}
 
Example 14
Source File: OutputImageTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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: InputImageTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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 16
Source File: OutputImageTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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 17
Source File: InputImageTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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 18
Source File: OutputImageTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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 19
Source File: InputImageTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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 20
Source File: OutputImageTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
}