Search in sources :

Example 11 with ImageReaderSpi

use of javax.imageio.spi.ImageReaderSpi in project jdk8u_jdk by JetBrains.

the class PNGSpiStreamMetadata method main.

public static void main(String[] args) {
    ImageReaderSpi rspi = new PNGImageReaderSpi();
    if (rspi.getNativeStreamMetadataFormatName() != null) {
        fatal();
    }
    if (rspi.isStandardStreamMetadataFormatSupported() != false) {
        fatal();
    }
    if (rspi.getExtraStreamMetadataFormatNames() != null) {
        fatal();
    }
    ImageWriterSpi wspi = new PNGImageWriterSpi();
    if (wspi.getNativeStreamMetadataFormatName() != null) {
        fatal();
    }
    if (wspi.isStandardStreamMetadataFormatSupported() != false) {
        fatal();
    }
    if (wspi.getExtraStreamMetadataFormatNames() != null) {
        fatal();
    }
}
Also used : ImageReaderSpi(javax.imageio.spi.ImageReaderSpi) PNGImageReaderSpi(com.sun.imageio.plugins.png.PNGImageReaderSpi) PNGImageWriterSpi(com.sun.imageio.plugins.png.PNGImageWriterSpi) PNGImageReaderSpi(com.sun.imageio.plugins.png.PNGImageReaderSpi) PNGImageWriterSpi(com.sun.imageio.plugins.png.PNGImageWriterSpi) ImageWriterSpi(javax.imageio.spi.ImageWriterSpi)

Example 12 with ImageReaderSpi

use of javax.imageio.spi.ImageReaderSpi in project jdk8u_jdk by JetBrains.

the class PluginSpiTest method testFormat.

public static void testFormat(String format) {
    ImageReader reader = ImageIO.getImageReadersByFormatName(format).next();
    if (reader == null) {
        throw new RuntimeException("Failed to get reader for " + format);
    }
    ImageReaderSpi readerSpi = reader.getOriginatingProvider();
    System.out.println(format + " Reader SPI: " + readerSpi);
    String[] writerSpiNames = readerSpi.getImageWriterSpiNames();
    if (writerSpiNames == null || writerSpiNames.length == 0) {
        throw new RuntimeException("Failed to get writer spi names for " + format);
    }
    System.out.println("Available writer spi names:");
    for (int i = 0; i < writerSpiNames.length; i++) {
        System.out.println(writerSpiNames[i]);
        try {
            Class spiClass = Class.forName(writerSpiNames[i]);
            if (spiClass == null) {
                throw new RuntimeException("Failed to get spi class " + writerSpiNames[i]);
            }
            System.out.println("Got class " + spiClass.getName());
            Object spiObject = spiClass.newInstance();
            if (spiObject == null) {
                throw new RuntimeException("Failed to instantiate spi " + writerSpiNames[i]);
            }
            System.out.println("Got instance " + spiObject);
        } catch (Throwable e) {
            throw new RuntimeException("Failed to test spi " + writerSpiNames[i]);
        }
    }
    ImageWriter writer = ImageIO.getImageWriter(reader);
    if (writer == null) {
        throw new RuntimeException("Failed to get writer for " + format);
    }
}
Also used : ImageReaderSpi(javax.imageio.spi.ImageReaderSpi) ImageWriter(javax.imageio.ImageWriter) ImageReader(javax.imageio.ImageReader)

Example 13 with ImageReaderSpi

use of javax.imageio.spi.ImageReaderSpi in project jdk8u_jdk by JetBrains.

the class CanDecodeTest method main.

public static void main(String[] args) throws IOException {
    ImageReader r = ImageIO.getImageReadersByFormatName("WBMP").next();
    ImageReaderSpi spi = r.getOriginatingProvider();
    Vector<TestCase> tests = getTestCases();
    for (TestCase t : tests) {
        t.doTest(spi);
    }
    System.out.println("Test passed.");
}
Also used : ImageReaderSpi(javax.imageio.spi.ImageReaderSpi) ImageReader(javax.imageio.ImageReader)

Aggregations

ImageReaderSpi (javax.imageio.spi.ImageReaderSpi)13 Iterator (java.util.Iterator)7 ImageReader (javax.imageio.ImageReader)5 IIORegistry (javax.imageio.spi.IIORegistry)5 ImageWriterSpi (javax.imageio.spi.ImageWriterSpi)5 IOException (java.io.IOException)3 ImageWriter (javax.imageio.ImageWriter)2 PNGImageReaderSpi (com.sun.imageio.plugins.png.PNGImageReaderSpi)1 PNGImageWriterSpi (com.sun.imageio.plugins.png.PNGImageWriterSpi)1 BufferedImage (java.awt.image.BufferedImage)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 Enumeration (java.util.Enumeration)1 Hashtable (java.util.Hashtable)1 List (java.util.List)1 IIOMetadataFormat (javax.imageio.metadata.IIOMetadataFormat)1 ImageTranscoderSpi (javax.imageio.spi.ImageTranscoderSpi)1 ServiceRegistry (javax.imageio.spi.ServiceRegistry)1 ImageInputStream (javax.imageio.stream.ImageInputStream)1