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


Java ImageReaderSpi.createReaderInstance方法代碼示例

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


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

示例1: getJPEGTablesReader

import javax.imageio.spi.ImageReaderSpi; //導入方法依賴的package包/類
/**
 * Retrieves a JPEG reader which supports native JPEG stream metadata.
 */
private static ImageReader getJPEGTablesReader() {
    ImageReader jpegReader = null;

    try {
        IIORegistry registry = IIORegistry.getDefaultInstance();
        Iterator<?> readerSPIs =
            registry.getServiceProviders(ImageReaderSpi.class,
                                         new JPEGSPIFilter(),
                                         true);
        if(readerSPIs.hasNext()) {
            ImageReaderSpi jpegReaderSPI =
                (ImageReaderSpi)readerSPIs.next();
            jpegReader = jpegReaderSPI.createReaderInstance();
        }
    } catch(Exception e) {
        // Ignore it ...
    }

    return jpegReader;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:24,代碼來源:TIFFJPEGCompressor.java

示例2: getJPEGTablesReader

import javax.imageio.spi.ImageReaderSpi; //導入方法依賴的package包/類
/**
 * Retrieves a JPEG reader which supports native JPEG stream metadata.
 */
private static ImageReader getJPEGTablesReader() {
    ImageReader jpegReader = null;

    try {
        IIORegistry registry = IIORegistry.getDefaultInstance();
        Class<?> imageReaderClass =
            Class.forName("javax.imageio.spi.ImageReaderSpi");
        Iterator<?> readerSPIs =
            registry.getServiceProviders(imageReaderClass,
                                         new JPEGSPIFilter(),
                                         true);
        if(readerSPIs.hasNext()) {
            ImageReaderSpi jpegReaderSPI =
                (ImageReaderSpi)readerSPIs.next();
            jpegReader = jpegReaderSPI.createReaderInstance();
        }
    } catch(Exception e) {
        // Ignore it ...
    }

    return jpegReader;
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:26,代碼來源:TIFFJPEGCompressor.java

示例3: 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

示例4: next

import javax.imageio.spi.ImageReaderSpi; //導入方法依賴的package包/類
public ImageReader next() {
    ImageReaderSpi spi = null;
    try {
        spi = iter.next();
        return spi.createReaderInstance();
    } catch (IOException e) {
        // Deregister the spi in this case, but only as
        // an ImageReaderSpi
        theRegistry.deregisterServiceProvider(spi, ImageReaderSpi.class);
    }
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:ImageIO.java

示例5: next

import javax.imageio.spi.ImageReaderSpi; //導入方法依賴的package包/類
public ImageReader next()
{
  try
    {
      ImageReaderSpi spi = it.next();
      return (readerExtension == null
          ? spi.createReaderInstance()
          : spi.createReaderInstance(readerExtension));
    }
  catch (IOException e)
    {
      return null;
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:15,代碼來源:ImageIO.java

示例6: Context

import javax.imageio.spi.ImageReaderSpi; //導入方法依賴的package包/類
Context(TestEnvironment env, Result result, int testType) {
    super(env, result);

    String content = (String)env.getModifier(contentList);
    if (content == null) {
        content = CONTENT_BLANK;
    }
    // REMIND: add option for non-opaque images
    image = createBufferedImage(size, size, content, false);

    result.setUnits(size*size);
    result.setUnitName("pixel");

    if (testType == TEST_IMAGEIO || testType == TEST_IMAGEREADER) {
        ImageReaderSpi readerspi =
            (ImageReaderSpi)env.getModifier(imageioReadFormatList);
        format = readerspi.getFileSuffixes()[0].toLowerCase();
        if (testType == TEST_IMAGEREADER) {
            seekForwardOnly = env.isEnabled(seekForwardOnlyTog);
            ignoreMetadata = env.isEnabled(ignoreMetadataTog);
            try {
                reader = readerspi.createReaderInstance();
            } catch (IOException e) {
                System.err.println("error creating reader");
                e.printStackTrace();
            }
            if (env.isEnabled(installListenerTog)) {
                reader.addIIOReadProgressListener(
                    new ReadProgressListener());
            }
        }
        if (format.equals("wbmp")) {
            // REMIND: this is a hack to create an image that the
            //         WBMPImageWriter can handle (a better approach
            //         would involve checking the ImageTypeSpecifier
            //         of the writer's default image param)
            BufferedImage newimg =
                new BufferedImage(size, size,
                                  BufferedImage.TYPE_BYTE_BINARY);
            Graphics g = newimg.createGraphics();
            g.drawImage(image, 0, 0, null);
            g.dispose();
            image = newimg;
        }
    } else if (testType == TEST_TOOLKIT) {
        format = (String)env.getModifier(toolkitReadFormatList);
    } else { // testType == TEST_JPEGCODEC
        format = "jpeg";
    }

    initInput();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:53,代碼來源:InputImageTests.java


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