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

📄 imagereader.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* ImageReader.java -- Decodes raster images.   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., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 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.Point;import java.awt.Rectangle;import java.awt.image.BufferedImage;import java.awt.image.Raster;import java.awt.image.RenderedImage;import java.io.IOException;import java.util.ArrayList;import java.util.Iterator;import java.util.List;import java.util.Locale;import java.util.ResourceBundle;import java.util.MissingResourceException;import java.util.Set;import javax.imageio.event.IIOReadProgressListener;import javax.imageio.event.IIOReadUpdateListener;import javax.imageio.event.IIOReadWarningListener;import javax.imageio.metadata.IIOMetadata;import javax.imageio.spi.ImageReaderSpi;import javax.imageio.stream.ImageInputStream;/** * A class for decoding images within the ImageIO framework. * * An ImageReader for a given format is instantiated by an * ImageReaderSpi for that format.  ImageReaderSpis are registered * with the IIORegistry. * * The ImageReader API supports reading animated images that may have * multiple frames; to support such images many methods take an index * parameter. * * Images may also be read in multiple passes, where each successive * pass increases the level of detail in the destination image. */public abstract class ImageReader{  private boolean aborted;  /**   * All locales available for localization of warning messages, or   * null if localization is not supported.   */  protected Locale[] availableLocales = null;  /**   * true if the input source does not require metadata to be read,   * false otherwise.   */  protected boolean ignoreMetadata = false;  /**   * An ImageInputStream from which image data is read.   */  protected Object input = null;  /**   * The current locale used to localize warning messages, or null if   * no locale has been set.   */  protected Locale locale = null;  /**   * The minimum index at which data can be read.  Constantly 0 if   * seekForwardOnly is false, always increasing if seekForwardOnly is   * true.   */  protected int minIndex = 0;  /**   * The image reader SPI that instantiated this reader.   */  protected ImageReaderSpi originatingProvider = null;  /**   * A list of installed progress listeners.  Initially null, meaning   * no installed listeners.   */  protected List progressListeners = null;  /**   * true if this reader should only read data further ahead in the   * stream than its current location.  false if it can read backwards   * in the stream.  If this is true then caching can be avoided.   */  protected boolean seekForwardOnly = false;  /**   * A list of installed update listeners.  Initially null, meaning no   * installed listeners.   */  protected List updateListeners = null;  /**   * A list of installed warning listeners.  Initially null, meaning   * no installed listeners.   */  protected List warningListeners = null;  /**   * A list of warning locales corresponding with the list of   * installed warning listeners.  Initially null, meaning no locales.   */  protected List warningLocales = null;  /**   * Construct an image reader.   *   * @param originatingProvider the provider that is constructing this   * image reader, or null   */  protected ImageReader(ImageReaderSpi originatingProvider)  {    this.originatingProvider = originatingProvider;  }  /**   * Request that reading be aborted.  The unread contents of the   * image will be undefined.   *   * Readers should clear the abort flag before starting a read   * operation, then poll it periodically during the read operation.   */  public void abort()  {    aborted = true;  }  /**   * Check if the abort flag is set.   *   * @return true if the current read operation should be aborted,   * false otherwise   */  protected boolean abortRequested()  {    return aborted;  }  /**   * Install a read progress listener.  This method will return   * immediately if listener is null.   *   * @param listener a read progress listener or null   */  public void addIIOReadProgressListener(IIOReadProgressListener listener)  {    if (listener == null)      return;    if (progressListeners == null)      progressListeners = new ArrayList ();    progressListeners.add(listener);  }  /**   * Install a read update listener.  This method will return   * immediately if listener is null.   *   * @param listener a read update listener   */  public void addIIOReadUpdateListener(IIOReadUpdateListener listener)  {    if (listener == null)      return;    if (updateListeners == null)      updateListeners = new ArrayList ();    updateListeners.add(listener);  }  /**   * Install a read warning listener.  This method will return   * immediately if listener is null.  Warning messages sent to this   * listener will be localized using the current locale.  If the   * current locale is null then this reader will select a sensible   * default.   *   * @param listener a read warning listener   */  public void addIIOReadWarningListener(IIOReadWarningListener listener)  {    if (listener == null)      return;    if (warningListeners == null)      warningListeners = new ArrayList ();    warningListeners.add(listener);  }  /**   * Check if this reader can handle raster data.  Determines whether   * or not readRaster and readTileRaster throw   * UnsupportedOperationException.   *   * @return true if this reader supports raster data, false if not   */  public boolean canReadRaster()  {    return false;  }  /**   * Clear the abort flag.   */  protected void clearAbortRequest()  {    aborted = false;  }  /**   * Releases any resources allocated to this object.  Subsequent   * calls to methods on this object will produce undefined results.   *   * The default implementation does nothing; subclasses should use   * this method ensure that native resources are released.   */  public void dispose()  {    // The default implementation does nothing.  }  /**   * Returns the aspect ratio of this image, the ration of its width   * to its height.  The aspect ratio is useful when resizing an image   * while keeping its proportions constant.   *   * @param imageIndex the frame index   *   * @return the image's aspect ratio   *   * @exception IllegalStateException if input is null   * @exception IndexOutOfBoundsException if the frame index is   * out-of-bounds   * @exception IOException if a read error occurs   */  public float getAspectRatio(int imageIndex)    throws IOException  {    if (input == null)      throw new IllegalStateException("input is null");    return (float) (getWidth(imageIndex) / getHeight(imageIndex));  }  /**   * Retrieve the available locales.  Return null if no locales are   * available or a clone of availableLocales.   *   * @return an array of locales or null   */  public Locale[] getAvailableLocales()  {    if (availableLocales == null)      return null;        return (Locale[]) availableLocales.clone();  }  /**   * Retrieve the default read parameters for this reader's image   * format.   *   * The default implementation returns new ImageReadParam().   *   * @return image reading parameters   */  public ImageReadParam getDefaultReadParam()  {    return new ImageReadParam();  }  /**   * Retrieve the format of the input source.   *   * @return the input source format name   *   * @exception IOException if a read error occurs   */  public String getFormatName()    throws IOException  {    return originatingProvider.getFormatNames()[0];  }  /**   * Get the height of the input image in pixels.  If the input image   * is resizable then a default height is returned.   *   * @param imageIndex the frame index   *   * @return the height of the input image   *   * @exception IllegalStateException if input has not been set   * @exception IndexOutOfBoundsException if the frame index is   * out-of-bounds   * @exception IOException if a read error occurs   */  public abstract int getHeight(int imageIndex)    throws IOException;  /**   * Get the metadata associated with this image.  If the reader is   * set to ignore metadata or does not support reading metadata, or   * if no metadata is available then null is returned.   *   * @param imageIndex the frame index   *   * @return a metadata object, or null   *   * @exception IllegalStateException if input has not been set   * @exception IndexOutOfBoundsException if the frame index is   * out-of-bounds   * @exception IOException if a read error occurs   */  public abstract IIOMetadata getImageMetadata(int imageIndex)    throws IOException;  /**   * Get an iterator over the collection of image types into which   * this reader can decode image data.  This method is guaranteed to   * return at least one valid image type specifier.   *   * The elements of the iterator should be ordered; the first element   * should be the most appropriate image type for this decoder,   * followed by the second-most appropriate, and so on.   *   * @param imageIndex the frame index   *   * @return an iterator over a collection of image type specifiers   *   * @exception IllegalStateException if input has not been set   * @exception IndexOutOfBoundsException if the frame index is   * out-of-bounds   * @exception IOException if a read error occurs   */  public abstract Iterator getImageTypes(int imageIndex)    throws IOException;  /**   * Set the input source to the given object, specify whether this   * reader should be allowed to read input from the data stream more   * than once, and specify whether this reader should ignore metadata   * in the input stream.  The input source must be set before many   * methods can be called on this reader. (see all ImageReader   * methods that throw IllegalStateException).  If input is null then   * the current input source will be removed.   *   * Unless this reader has direct access with imaging hardware, input   * should be an ImageInputStream.   *   * @param input the input source object   * @param seekForwardOnly true if this reader should be allowed to   * read input from the data stream more than once, false otherwise   * @param ignoreMetadata true if this reader should ignore metadata   * associated with the input source, false otherwise   *   * @exception IllegalArgumentException if input is not a valid input   * source for this reader and is not an ImageInputStream   */  public void setInput(Object input,                       boolean seekForwardOnly,                       boolean ignoreMetadata)  {    Class[] okClasses = originatingProvider.getInputTypes();    if (okClasses == null)      {        if (!(input instanceof ImageInputStream))          throw new IllegalArgumentException();      }    else

⌨️ 快捷键说明

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