當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageReader.getOriginatingProvider方法代碼示例

本文整理匯總了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");

}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:30,代碼來源:StreamResetTest.java

示例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.");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:12,代碼來源:CanDecodeTest.java

示例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.");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:31,代碼來源:TestSIMPPlugin.java

示例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);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:45,代碼來源:PluginSpiTest.java


注:本文中的javax.imageio.ImageReader.getOriginatingProvider方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。