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


Java ImageReaderSpi.canDecodeInput方法代碼示例

本文整理匯總了Java中javax.imageio.spi.ImageReaderSpi.canDecodeInput方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageReaderSpi.canDecodeInput方法的具體用法?Java ImageReaderSpi.canDecodeInput怎麽用?Java ImageReaderSpi.canDecodeInput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.imageio.spi.ImageReaderSpi的用法示例。


在下文中一共展示了ImageReaderSpi.canDecodeInput方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doTest

import javax.imageio.spi.ImageReaderSpi; //導入方法依賴的package包/類
public void doTest(ImageReaderSpi spi) throws IOException {
    System.out.println("Test for " + title +
            (canDecode ? " (can decode)" : " (can't decode)"));
    System.out.print("As a stream...");
    ImageInputStream iis =
            ImageIO.createImageInputStream(getDataStream());

    if (spi.canDecodeInput(iis) != canDecode) {
        throw new RuntimeException("Test failed: wrong decideion " +
                "for stream data");
    }
    System.out.println("OK");

    System.out.print("As a file...");
    iis = ImageIO.createImageInputStream(getDataFile());
    if (spi.canDecodeInput(iis) != canDecode) {
        throw new RuntimeException("Test failed: wrong decideion " +
                "for file data");
    }
    System.out.println("OK");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:22,代碼來源:CanDecodeTest.java

示例2: filter

import javax.imageio.spi.ImageReaderSpi; //導入方法依賴的package包/類
public boolean filter(Object elt) {
    try {
        ImageReaderSpi spi = (ImageReaderSpi)elt;
        ImageInputStream stream = null;
        if (input instanceof ImageInputStream) {
            stream = (ImageInputStream)input;
        }

        // Perform mark/reset as a defensive measure
        // even though plug-ins are supposed to take
        // care of it.
        boolean canDecode = false;
        if (stream != null) {
            stream.mark();
        }
        canDecode = spi.canDecodeInput(input);
        if (stream != null) {
            stream.reset();
        }

        return canDecode;
    } catch (IOException e) {
        return false;
    }
}
 
開發者ID:Java8-CNAPI-Team,項目名稱:Java8CN,代碼行數:26,代碼來源:ImageIO.java

示例3: filter

import javax.imageio.spi.ImageReaderSpi; //導入方法依賴的package包/類
public boolean filter(Object provider)
{
  if (provider instanceof ImageReaderSpi)
    {
      ImageReaderSpi spi = (ImageReaderSpi) provider;

      try
        {
          if (spi.canDecodeInput(object))
            return true;
        }
      catch (IOException e)
        {
          // Return false in this case
        }
    }
  return false;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:19,代碼來源:ImageIO.java

示例4: read

import javax.imageio.spi.ImageReaderSpi; //導入方法依賴的package包/類
/**
 * Create a buffered image from an image input stream.  An image
 * reader that supports the given image data is automatically
 * selected from the collection of registered readers.  If no
 * registered reader can handle the input format, null is returned.
 *
 * @param stream the image input stream from which to read image
 * data
 *
 * @return a new buffered image created from the given image data,
 * or null
 *
 * @exception IllegalArgumentException if stream is null
 * @exception IOException if a reading error occurs
 */
public static BufferedImage read(ImageInputStream stream)
  throws IOException
{
  if (stream == null)
    throw new IllegalArgumentException("null argument");

  Iterator providers = getRegistry().getServiceProviders(ImageReaderSpi.class, true);
  while (providers.hasNext())
    {
      ImageReaderSpi spi = (ImageReaderSpi) providers.next();
      if (spi.canDecodeInput(stream))
        {
          ImageReader reader = spi.createReaderInstance();
          reader.setInput(stream);
          return reader.read(0, null);
        }
    }
  return null;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:35,代碼來源:ImageIO.java

示例5: main

import javax.imageio.spi.ImageReaderSpi; //導入方法依賴的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

示例6: filter

import javax.imageio.spi.ImageReaderSpi; //導入方法依賴的package包/類
public boolean filter(Object elt) {
    try {
        ImageReaderSpi spi = (ImageReaderSpi)elt;
        ImageInputStream stream = null;
        if (input instanceof ImageInputStream) {
            stream = (ImageInputStream)input;
        }

        // Perform mark/reset as a defensive measure
        // even though plug-ins are supposed to take
        // care of it.
        boolean canDecode = false;
        if (stream != null) {
            stream.mark();
        }
        try {
            canDecode = spi.canDecodeInput(input);
        } finally {
            if (stream != null) {
                stream.reset();
            }
        }

        return canDecode;
    } catch (IOException e) {
        return false;
    }
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:29,代碼來源:ImageIO.java


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