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

📄 imageio.java

📁 Mac OS X 10.4.9 for x86 Source Code gcc 实现源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* ImageIO.java --   Copyright (C) 2004, 2005  Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package javax.imageio;import java.awt.image.BufferedImage;import java.awt.image.RenderedImage;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.net.URL;import java.util.ArrayList;import java.util.Collections;import java.util.Iterator;import javax.imageio.spi.IIORegistry;import javax.imageio.spi.ImageReaderSpi;import javax.imageio.spi.ImageWriterSpi;import javax.imageio.spi.ServiceRegistry;import javax.imageio.stream.ImageInputStream;import javax.imageio.stream.ImageOutputStream;import javax.imageio.stream.MemoryCacheImageInputStream;import javax.imageio.stream.MemoryCacheImageOutputStream;public final class ImageIO{  /**   * This class isn't intended to be instantiated.   */  private ImageIO() {}  private static final class ReaderFormatFilter implements ServiceRegistry.Filter  {    private String formatName;    public ReaderFormatFilter(String formatName)    {      this.formatName = formatName;    }    public boolean filter (Object provider)    {      if (provider instanceof ImageReaderSpi)        {          ImageReaderSpi spi = (ImageReaderSpi) provider;          String[] formatNames = spi.getFormatNames();          for (int i = formatNames.length - 1; i >= 0; --i)            if (formatName.equals(formatNames[i]))              return true;        }      return false;    }  }  private static final class ReaderMIMETypeFilter implements ServiceRegistry.Filter  {    private String MIMEType;    public ReaderMIMETypeFilter(String MIMEType)    {      this.MIMEType = MIMEType;    }    public boolean filter(Object provider)    {      if (provider instanceof ImageReaderSpi)        {          ImageReaderSpi spi = (ImageReaderSpi) provider;          String[] mimetypes = spi.getMIMETypes();          for (int i = mimetypes.length - 1; i >= 0; --i)            if (MIMEType.equals(mimetypes[i]))              return true;        }      return false;    }  }    private static final class ReaderSuffixFilter implements ServiceRegistry.Filter  {    private String fileSuffix;    public ReaderSuffixFilter(String fileSuffix)    {      this.fileSuffix = fileSuffix;    }    public boolean filter(Object provider)    {      if (provider instanceof ImageReaderSpi)        {          ImageReaderSpi spi = (ImageReaderSpi) provider;          String[] suffixes = spi.getFileSuffixes();          for (int i = suffixes.length - 1; i >= 0; --i)            if (fileSuffix.equals(suffixes[i]))              return true;        }      return false;    }  }    private static final class WriterFormatFilter implements ServiceRegistry.Filter  {    private String formatName;    public WriterFormatFilter(String formatName)    {      this.formatName = formatName;    }    public boolean filter(Object provider)    {      if (provider instanceof ImageWriterSpi)	{	  ImageWriterSpi spi = (ImageWriterSpi) provider;	  String[] formatNames = spi.getFormatNames();	  	  for (int i = formatNames.length - 1; i >= 0; --i)            if (formatName.equals(formatNames[i]))              return true;	}      return false;    }  }  private static final class WriterMIMETypeFilter implements ServiceRegistry.Filter  {    private String MIMEType;    public WriterMIMETypeFilter(String MIMEType)    {      this.MIMEType = MIMEType;    }    public boolean filter(Object provider)    {      if (provider instanceof ImageWriterSpi)        {          ImageWriterSpi spi = (ImageWriterSpi) provider;          String[] mimetypes = spi.getMIMETypes();          for (int i = mimetypes.length - 1; i >= 0; --i)            if (MIMEType.equals(mimetypes[i]))              return true;        }      return false;    }  }    private static final class WriterSuffixFilter implements ServiceRegistry.Filter  {    private String fileSuffix;    public WriterSuffixFilter(String fileSuffix)    {      this.fileSuffix = fileSuffix;    }    public boolean filter(Object provider)    {      if (provider instanceof ImageWriterSpi)        {          ImageWriterSpi spi = (ImageWriterSpi) provider;          String[] suffixes = spi.getFileSuffixes();          for (int i = suffixes.length - 1; i >= 0; --i)            if (fileSuffix.equals(suffixes[i]))              return true;        }      return false;    }  }  private static final class ImageReaderIterator implements Iterator  {    Iterator it;    Object readerExtension;        public ImageReaderIterator(Iterator it, Object readerExtension)    {      this.it = it;      this.readerExtension = readerExtension;    }    public boolean hasNext()    {      return it.hasNext();    }    public Object next()    {      try        {          return ((ImageReaderSpi) it.next()).createReaderInstance(readerExtension);        }      catch (IOException e)        {          return null;        }    }    public void remove()    {      throw new UnsupportedOperationException();    }  }  private static final class ImageWriterIterator implements Iterator  {    Iterator it;    Object writerExtension;        public ImageWriterIterator(Iterator it, Object writerExtension)    {      this.it = it;      this.writerExtension = writerExtension;    }    public boolean hasNext()    {      return it.hasNext();    }    public Object next()    {      try        {          return ((ImageWriterSpi) it.next()).createWriterInstance(writerExtension);        }      catch (IOException e)        {          return null;        }    }    public void remove()    {      throw new UnsupportedOperationException();    }  }    private static File cacheDirectory;  private static boolean useCache = true;  private static Iterator getReadersByFilter(Class type,                                             ServiceRegistry.Filter filter,                                             Object readerExtension)  {    try      {        Iterator it = getRegistry().getServiceProviders(type, filter, true);        return new ImageReaderIterator(it, readerExtension);      }    catch (IllegalArgumentException e)      {        return Collections.EMPTY_SET.iterator();      }

⌨️ 快捷键说明

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