Java Code Examples for javax.imageio.ImageReader#getOriginatingProvider()

The following examples show how to use javax.imageio.ImageReader#getOriginatingProvider() . 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: ImageIOGreyScale.java    From multimedia-indexing with Apache License 2.0 6 votes vote down vote up
/**
 * Returns an <code>Iterator</code> containing all currently registered <code>ImageTranscoder</code>s that
 * claim to be able to transcode between the metadata of the given <code>ImageReader</code> and
 * <code>ImageWriter</code>.
 * 
 * @param reader
 *            an <code>ImageReader</code>.
 * @param writer
 *            an <code>ImageWriter</code>.
 * 
 * @return an <code>Iterator</code> containing <code>ImageTranscoder</code>s.
 * 
 * @exception IllegalArgumentException
 *                if <code>reader</code> or <code>writer</code> is <code>null</code>.
 */
public static Iterator<ImageTranscoder> getImageTranscoders(ImageReader reader, ImageWriter writer) {
	if (reader == null) {
		throw new IllegalArgumentException("reader == null!");
	}
	if (writer == null) {
		throw new IllegalArgumentException("writer == null!");
	}
	ImageReaderSpi readerSpi = reader.getOriginatingProvider();
	ImageWriterSpi writerSpi = writer.getOriginatingProvider();
	ServiceRegistry.Filter filter = new TranscoderFilter(readerSpi, writerSpi);

	Iterator iter;
	// Ensure category is present
	try {
		iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class, filter, true);
	} catch (IllegalArgumentException e) {
		return new HashSet().iterator();
	}
	return new ImageTranscoderIterator(iter);
}
 
Example 2
Source File: CanDecodeTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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.");
}
 
Example 3
Source File: CanDecodeTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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.");
}
 
Example 4
Source File: CanDecodeTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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.");
}
 
Example 5
Source File: StreamResetTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    IOException expectedException = null;
    TestStream iis = new TestStream();

    ImageReader wbmp = ImageIO.getImageReadersByFormatName("WBMP").next();
    if (wbmp == null) {
        System.out.println("No WBMP reader: skip the test");
        return;
    }

    ImageReaderSpi spi = wbmp.getOriginatingProvider();

    iis.checkPosition();

    try {
        spi.canDecodeInput(iis);
    } catch (IOException e) {
        expectedException = e;
    }

    if (expectedException == null) {
        throw new RuntimeException("Test FAILED: stream was not used");
    }

    iis.checkPosition();

    System.out.println("Test PASSED");

}
 
Example 6
Source File: CanDecodeTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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.");
}
 
Example 7
Source File: StreamResetTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    IOException expectedException = null;
    TestStream iis = new TestStream();

    ImageReader wbmp = ImageIO.getImageReadersByFormatName("WBMP").next();
    if (wbmp == null) {
        System.out.println("No WBMP reader: skip the test");
        return;
    }

    ImageReaderSpi spi = wbmp.getOriginatingProvider();

    iis.checkPosition();

    try {
        spi.canDecodeInput(iis);
    } catch (IOException e) {
        expectedException = e;
    }

    if (expectedException == null) {
        throw new RuntimeException("Test FAILED: stream was not used");
    }

    iis.checkPosition();

    System.out.println("Test PASSED");

}
 
Example 8
Source File: StreamResetTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    IOException expectedException = null;
    TestStream iis = new TestStream();

    ImageReader wbmp = ImageIO.getImageReadersByFormatName("WBMP").next();
    if (wbmp == null) {
        System.out.println("No WBMP reader: skip the test");
        return;
    }

    ImageReaderSpi spi = wbmp.getOriginatingProvider();

    iis.checkPosition();

    try {
        spi.canDecodeInput(iis);
    } catch (IOException e) {
        expectedException = e;
    }

    if (expectedException == null) {
        throw new RuntimeException("Test FAILED: stream was not used");
    }

    iis.checkPosition();

    System.out.println("Test PASSED");

}
 
Example 9
Source File: CanDecodeTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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.");
}
 
Example 10
Source File: StreamResetTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    IOException expectedException = null;
    TestStream iis = new TestStream();

    ImageReader wbmp = ImageIO.getImageReadersByFormatName("WBMP").next();
    if (wbmp == null) {
        System.out.println("No WBMP reader: skip the test");
        return;
    }

    ImageReaderSpi spi = wbmp.getOriginatingProvider();

    iis.checkPosition();

    try {
        spi.canDecodeInput(iis);
    } catch (IOException e) {
        expectedException = e;
    }

    if (expectedException == null) {
        throw new RuntimeException("Test FAILED: stream was not used");
    }

    iis.checkPosition();

    System.out.println("Test PASSED");

}
 
Example 11
Source File: StreamResetTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    IOException expectedException = null;
    TestStream iis = new TestStream();

    ImageReader wbmp = ImageIO.getImageReadersByFormatName("WBMP").next();
    if (wbmp == null) {
        System.out.println("No WBMP reader: skip the test");
        return;
    }

    ImageReaderSpi spi = wbmp.getOriginatingProvider();

    iis.checkPosition();

    try {
        spi.canDecodeInput(iis);
    } catch (IOException e) {
        expectedException = e;
    }

    if (expectedException == null) {
        throw new RuntimeException("Test FAILED: stream was not used");
    }

    iis.checkPosition();

    System.out.println("Test PASSED");

}
 
Example 12
Source File: CanDecodeTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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.");
}
 
Example 13
Source File: StreamResetTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    IOException expectedException = null;
    TestStream iis = new TestStream();

    ImageReader wbmp = ImageIO.getImageReadersByFormatName("WBMP").next();
    if (wbmp == null) {
        System.out.println("No WBMP reader: skip the test");
        return;
    }

    ImageReaderSpi spi = wbmp.getOriginatingProvider();

    iis.checkPosition();

    try {
        spi.canDecodeInput(iis);
    } catch (IOException e) {
        expectedException = e;
    }

    if (expectedException == null) {
        throw new RuntimeException("Test FAILED: stream was not used");
    }

    iis.checkPosition();

    System.out.println("Test PASSED");

}
 
Example 14
Source File: CanDecodeTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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.");
}
 
Example 15
Source File: CanDecodeTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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.");
}
 
Example 16
Source File: StreamResetTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    IOException expectedException = null;
    TestStream iis = new TestStream();

    ImageReader wbmp = ImageIO.getImageReadersByFormatName("WBMP").next();
    if (wbmp == null) {
        System.out.println("No WBMP reader: skip the test");
        return;
    }

    ImageReaderSpi spi = wbmp.getOriginatingProvider();

    iis.checkPosition();

    try {
        spi.canDecodeInput(iis);
    } catch (IOException e) {
        expectedException = e;
    }

    if (expectedException == null) {
        throw new RuntimeException("Test FAILED: stream was not used");
    }

    iis.checkPosition();

    System.out.println("Test PASSED");

}
 
Example 17
Source File: StreamResetTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    IOException expectedException = null;
    TestStream iis = new TestStream();

    ImageReader wbmp = ImageIO.getImageReadersByFormatName("WBMP").next();
    if (wbmp == null) {
        System.out.println("No WBMP reader: skip the test");
        return;
    }

    ImageReaderSpi spi = wbmp.getOriginatingProvider();

    iis.checkPosition();

    try {
        spi.canDecodeInput(iis);
    } catch (IOException e) {
        expectedException = e;
    }

    if (expectedException == null) {
        throw new RuntimeException("Test FAILED: stream was not used");
    }

    iis.checkPosition();

    System.out.println("Test PASSED");

}
 
Example 18
Source File: StreamResetTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    IOException expectedException = null;
    TestStream iis = new TestStream();

    ImageReader wbmp = ImageIO.getImageReadersByFormatName("WBMP").next();
    if (wbmp == null) {
        System.out.println("No WBMP reader: skip the test");
        return;
    }

    ImageReaderSpi spi = wbmp.getOriginatingProvider();

    iis.checkPosition();

    try {
        spi.canDecodeInput(iis);
    } catch (IOException e) {
        expectedException = e;
    }

    if (expectedException == null) {
        throw new RuntimeException("Test FAILED: stream was not used");
    }

    iis.checkPosition();

    System.out.println("Test PASSED");

}
 
Example 19
Source File: PluginSpiTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
}
 
Example 20
Source File: PluginSpiTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
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);
    }
}