⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imageio.java

📁 linux下建立JAVA虚拟机的源码KAFFE
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
      }  }    private static Iterator getWritersByFilter(Class type,					     ServiceRegistry.Filter filter,                                             Object writerExtension)  {    try      {        Iterator it = getRegistry().getServiceProviders(type, filter, true);        return new ImageWriterIterator(it, writerExtension);      }    catch (IllegalArgumentException e)      {        return Collections.EMPTY_SET.iterator();      }  }  /**   * Retrieve the current cache directory.   *   * @return the current cache directory or null if none is set.   */  public static File getCacheDirectory()  {    return cacheDirectory;  }  /**   * Retrieve an iterator over all registered readers for the given   * format.   *   * @param formatName an infomal format name (e.g. "jpeg" or "bmp")   *   * @return an iterator over a collection of image readers   *   * @exception IllegalArgumentException if formatName is null   */  public static Iterator getImageReadersByFormatName(String formatName)  {    if (formatName == null)      throw new IllegalArgumentException("formatName may not be null");    return getReadersByFilter(ImageReaderSpi.class,                              new ReaderFormatFilter(formatName),                              formatName);  }  /**   * Retrieve an iterator over all registered readers for the given   * MIME type.   *   * @param MIMEType a MIME specification for an image type   * (e.g. "image/jpeg" or "image/x-bmp")   *   * @return an iterator over a collection of image readers   *   * @exception IllegalArgumentException if MIMEType is null   */  public static Iterator getImageReadersByMIMEType(String MIMEType)  {    if (MIMEType == null)      throw new IllegalArgumentException("MIMEType may not be null");    return getReadersByFilter(ImageReaderSpi.class,                              new ReaderMIMETypeFilter(MIMEType),                              MIMEType);  }  /**   * Retrieve an iterator over all registered readers for the given   * file suffix.   *   * @param fileSuffix an image file suffix (e.g. "jpg" or "bmp")   *   * @return an iterator over a collection of image readers   *   * @exception IllegalArgumentException if fileSuffix is null   */  public static Iterator getImageReadersBySuffix(String fileSuffix)  {    if (fileSuffix == null)      throw new IllegalArgumentException("formatName may not be null");        return getReadersByFilter(ImageReaderSpi.class,                              new ReaderSuffixFilter(fileSuffix),                              fileSuffix);  }  /**   * Retrieve an iterator over all registered writers for the given   * format.   *   * @param formatName an infomal format name (e.g. "jpeg" or "bmp")   *   * @return an iterator over a collection of image writers   *   * @exception IllegalArgumentException if formatName is null   */  public static Iterator getImageWritersByFormatName(String formatName)  {    if (formatName == null)      throw new IllegalArgumentException("formatName may not be null");        return getWritersByFilter(ImageWriterSpi.class,                              new WriterFormatFilter(formatName),                              formatName);  }  /**   * Retrieve an iterator over all registered writers for the given   * MIME type.   *   * @param MIMEType a MIME specification for an image type   * (e.g. "image/jpeg" or "image/x-bmp")   *   * @return an iterator over a collection of image writers   *   * @exception IllegalArgumentException if MIMEType is null   */  public static Iterator getImageWritersByMIMEType(String MIMEType)  {    if (MIMEType == null)      throw new IllegalArgumentException("MIMEType may not be null");        return getWritersByFilter(ImageWriterSpi.class,                              new WriterMIMETypeFilter(MIMEType),                              MIMEType);  }  /**   * Retrieve an iterator over all registered writers for the given   * file suffix.   *   * @param fileSuffix an image file suffix (e.g. "jpg" or "bmp")   *   * @return an iterator over a collection of image writers   *   * @exception IllegalArgumentException if fileSuffix is null   */  public static Iterator getImageWritersBySuffix(String fileSuffix)  {    if (fileSuffix == null)      throw new IllegalArgumentException("fileSuffix may not be null");        return getWritersByFilter(ImageWriterSpi.class,                              new WriterSuffixFilter(fileSuffix),                              fileSuffix);  }  /**   * Retrieve all the informal format names supported by the   * collection of registered image readers.   *   * @return an array of format names   */  public static String[] getReaderFormatNames()  {    try      {        Iterator it =	  getRegistry().getServiceProviders(ImageReaderSpi.class, true);	ArrayList result = new ArrayList();	while (it.hasNext())	  {	    ImageReaderSpi spi = (ImageReaderSpi) it.next();	    String[] names = spi.getFormatNames();	    for (int i = names.length - 1; i >= 0; --i)	      result.add(names[i]);	  }	return (String[]) result.toArray(new String[result.size()]);      }    catch (IllegalArgumentException e)      {        return new String[0];      }  }  /**   * Retrieve all the MIME types supported by the collection of   * registered image readers.   *   * @return an array of MIME types   */  public static String[] getReaderMIMETypes()  {    try      {        Iterator it =	  getRegistry().getServiceProviders(ImageReaderSpi.class, true);	ArrayList result = new ArrayList();	while (it.hasNext())	  {	    ImageReaderSpi spi = (ImageReaderSpi) it.next();	    String[] names = spi.getMIMETypes();	    for (int i = names.length - 1; i >= 0; --i)	      result.add(names[i]);	  }	return (String[]) result.toArray(new String[result.size()]);      }    catch (IllegalArgumentException e)      {        return new String[0];      }  }  private static IIORegistry getRegistry()  {    return IIORegistry.getDefaultInstance();  }  /**   * Check whether or not an on-disk cache is used for image input and   * output streams.   *   * @return true if an on-disk cache is available, false otherwise   */  public static boolean getUseCache()  {    return useCache;  }  /**   * Retrieve all the informal format names supported by the   * collection of registered image writers.   *   * @return an array of format names   */  public static String[] getWriterFormatNames()  {    try      {        Iterator it =	  getRegistry().getServiceProviders(ImageWriterSpi.class, true);	ArrayList result = new ArrayList();	while (it.hasNext())	  {	    ImageWriterSpi spi = (ImageWriterSpi) it.next();	    String[] names = spi.getFormatNames();	    for (int i = names.length - 1; i >= 0; --i)	      result.add(names[i]);	  }	return (String[]) result.toArray(new String[result.size()]);      }    catch (IllegalArgumentException e)      {        return new String[0];      }  }  /**   * Retrieve all the MIME types supported by the collection of   * registered image writers.   *   * @return an array of MIME types   */  public static String[] getWriterMIMETypes()  {    try      {        Iterator it =	  getRegistry().getServiceProviders(ImageWriterSpi.class, true);	ArrayList result = new ArrayList();	while (it.hasNext())	  {	    ImageWriterSpi spi = (ImageWriterSpi) it.next();	    String[] names = spi.getMIMETypes();	    for (int i = names.length - 1; i >= 0; --i)	      result.add(names[i]);	  }	return (String[]) result.toArray(new String[result.size()]);      }    catch (IllegalArgumentException e)      {        return new String[0];      }  }    /**   * Rescans the application classpath for ImageIO service providers   * and registers them.   */  public static void scanForPlugins()  {    IIORegistry.getDefaultInstance().registerApplicationClasspathSpis();  }  /**   * Set the directory to be used for caching image data.  A null   * argument means to use the default system temporary directory.   * This cache directory is only used if getUseCache returns true.   *   * @param cacheDirectory the directory where image data should be   * cached   *   * @exception IllegalArgumentException if cacheDirectory is not a   * directory   */  public static void setCacheDirectory(File cacheDirectory)  {    // FIXME: add SecurityManager call    if (cacheDirectory != null)      {        if (!cacheDirectory.isDirectory())          throw new IllegalArgumentException("cacheDirectory must be a directory");        cacheDirectory.canWrite();      }        ImageIO.cacheDirectory = cacheDirectory;  }  /**   * Control whether or not an on-disk cache is used.  This cache is   * used to store input or output data from an image data stream when   * data in the stream needs to be re-processed.   *   * If useCache is false the cache will be stored in memory.  Doing   * so eliminates file creation and deletion overhead.  The default   * is to use an on-disk cache.   *   * @param useCache true to use an on-disk cache, false otherwise   */  public static void setUseCache(boolean useCache)  {    ImageIO.useCache = useCache;  }  /**   * Write an image to a file using a registered writer that supports   * the given format, overwriting the file if it already exists.   *   * @param im the image data to write   * @param formatName an informal description of the output format   * @param output the file to which the image will be written   *   * @return false if no registered writer supports the given format,   * true otherwise   *   * @exception IllegalArgumentException if any argument is null   * @exception IOException if a writing error occurs   */  public static boolean write(RenderedImage im,                              String formatName,                              File output)    throws IOException  {    if (im == null || formatName == null || output == null)      throw new IllegalArgumentException ("null argument");    return write(im, formatName, new FileOutputStream(output));  }  /**   * Write an image to an output stream using a registered writer that   * supports the given format.   *   * @param im the image data to write   * @param formatName an informal description of the output format   * @param output the output stream to which the image will be   * written   *   * @return false if no registered writer supports the given format,   * true otherwise   *   * @exception IllegalArgumentException if any argument is null   * @exception IOException if a writing error occurs   */  public static boolean write(RenderedImage im,                              String formatName,                              OutputStream output)    throws IOException  {    if (im == null || formatName == null || output == null)      throw new IllegalArgumentException ("null argument");    return write(im, formatName, new MemoryCacheImageOutputStream(output));  }  /**   * Write an image to an ImageOutputStream using a registered writer   * that supports the given format.  Image data is written starting   * at the ImageOutputStream's current stream pointer, overwriting   * any existing data.   *   * @param im the image data to write   * @param formatName an informal description of the output format   * @param output the image output stream to which the image will be

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -