本文整理汇总了Java中javax.imageio.ImageReader.getOriginatingProvider方法的典型用法代码示例。如果您正苦于以下问题:Java ImageReader.getOriginatingProvider方法的具体用法?Java ImageReader.getOriginatingProvider怎么用?Java ImageReader.getOriginatingProvider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.imageio.ImageReader
的用法示例。
在下文中一共展示了ImageReader.getOriginatingProvider方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.imageio.ImageReader; //导入方法依赖的package包/类
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");
}
示例2: main
import javax.imageio.ImageReader; //导入方法依赖的package包/类
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.");
}
示例3: main
import javax.imageio.ImageReader; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
Iterator<ImageReader> readers = ImageIO.getImageReadersBySuffix("simp");
ImageReader simpReader = null;
if (readers.hasNext()) {
simpReader = readers.next();
System.out.println("reader="+simpReader);
}
if (simpReader == null) {
throw new RuntimeException("Reader not found.");
}
ImageReaderSpi spi = simpReader.getOriginatingProvider();
IIOMetadataFormat spiFmt =
spi.getImageMetadataFormat("simp_metadata_1.0");
System.out.println("fmt from SPI=" + spiFmt);
ByteArrayInputStream bais = new ByteArrayInputStream(simpData);
ImageInputStream iis = new MemoryCacheImageInputStream(bais);
simpReader.setInput(iis);
BufferedImage bi = simpReader.read(0);
System.out.println(bi);
IIOMetadata metadata = simpReader.getImageMetadata(0);
System.out.println("Image metadata="+metadata);
IIOMetadataFormat format =
metadata.getMetadataFormat("simp_metadata_1.0");
System.out.println("Image metadata format="+format);
if (format == null) {
throw new RuntimeException("MetadataFormat not found.");
}
}
示例4: testFormat
import javax.imageio.ImageReader; //导入方法依赖的package包/类
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);
}
}