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

📄 imagereader.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                      {                        dest = t.createBufferedImage (width, height);                        break;                      }                    if (destType == null)                      throw new IIOException ("invalid destination type");                  }              }          }      }    if (dest == null)      {        Rectangle srcRegion = new Rectangle ();        Rectangle destRegion = new Rectangle ();        computeRegions (param, width, height, null, srcRegion, destRegion);        if (destRegion.isEmpty())          throw new IllegalArgumentException ("destination region empty");        if (destType == null)          {            Object o = imageTypes.next();            if (! (o instanceof ImageTypeSpecifier))              throw new IllegalArgumentException ("non-ImageTypeSpecifier"                                                  + " object");            dest = ((ImageTypeSpecifier) o).createBufferedImage              (destRegion.width, destRegion.height);          }        else          dest = destType.createBufferedImage            (destRegion.width, destRegion.height);      }    return dest;  }  /**   * 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.   *   * This more specific version of getImageMetadata(int) can be used   * to restrict metadata retrieval to specific formats and node   * names, which can limit the amount of data that needs to be   * processed.   *   * @param imageIndex the frame index   * @param formatName the format of metadata requested   * @param nodeNames a set of Strings specifiying node names to be   * retrieved   *   * @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 IllegalArgumentException if formatName is null   * @exception IllegalArgumentException if nodeNames is null   * @exception IOException if a read error occurs   */  public IIOMetadata getImageMetadata (int imageIndex,                                       String formatName,                                       Set nodeNames)    throws IOException  {    if (formatName == null || nodeNames == null)      throw new IllegalArgumentException ("null argument");    return getImageMetadata (imageIndex);  }  /**   * Get the index at which the next image will be read.  If   * seekForwardOnly is true then the returned value will increase   * monotonically each time an image frame is read.  If   * seekForwardOnly is false then the returned value will always be   * 0.   *   * @return the current frame index   */  public int getMinIndex()  {    return minIndex;  }  /**   * Get the image type specifier that most closely represents the   * internal data representation used by this reader.  This value   * should be included in the return value of getImageTypes.   *   * @param imageIndex the frame index   *   * @return an image type specifier   *   * @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 ImageTypeSpecifier getRawImageType (int imageIndex)    throws IOException  {    return (ImageTypeSpecifier) getImageTypes(imageIndex).next();  }  /**   * Calculate a source region based on the given source image   * dimensions and parameters.  Subsampling offsets and a source   * region are taken from the given image read parameters and used to   * clip the given image dimensions, returning a new rectangular   * region as a result.   *   * @param param image parameters, or null   * @param srcWidth the width of the source image   * @param srcHeight the height of the source image   *   * @return a clipped rectangle   */  protected static Rectangle getSourceRegion (ImageReadParam param,					      int srcWidth,					      int srcHeight)  {    Rectangle clippedRegion = new Rectangle (0, 0, srcWidth, srcHeight);    if (param != null)      {        Rectangle srcRegion = param.getSourceRegion();        if (srcRegion != null)          {            clippedRegion.x = srcRegion.x > clippedRegion.x              ? srcRegion.x : clippedRegion.x;            clippedRegion.y = srcRegion.y > clippedRegion.y              ? srcRegion.y : clippedRegion.y;            clippedRegion.width = srcRegion.width > clippedRegion.width              ? srcRegion.width : clippedRegion.width;            clippedRegion.height = srcRegion.height > clippedRegion.height              ? srcRegion.height : clippedRegion.height;          }        int xOffset = param.getSubsamplingXOffset();        clippedRegion.x += xOffset;        clippedRegion.width -= xOffset;        int yOffset = param.getSubsamplingYOffset();        clippedRegion.y += yOffset;        clippedRegion.height -= yOffset;      }    return clippedRegion;  }  /**   * Get the metadata associated with the image being read.  If the   * reader is set to ignore metadata or does not support reading   * metadata, or if no metadata is available then null is returned.   * This method returns metadata associated with the entirety of the   * image data, whereas getStreamMetadata() returns metadata   * associated with a frame within a multi-image data stream.   *   * This more specific version of getStreamMetadata() can be used to   * restrict metadata retrieval to specific formats and node names,   * which can limit the amount of data that needs to be processed.   *   * @param formatName the format of metadata requested   * @param nodeNames a set of Strings specifiying node names to be   * retrieved   *   * @return metadata associated with the image being read, or null   *   * @exception IllegalArgumentException if formatName is null   * @exception IllegalArgumentException if nodeNames is null   * @exception IOException if a read error occurs   */  public IIOMetadata getStreamMetadata (String formatName,                                        Set nodeNames)    throws IOException  {    if (formatName == null || nodeNames == null)      throw new IllegalArgumentException ("null argument");    return getStreamMetadata();  }  /**   * Read the given frame all at once, using default image read   * parameters, and return a buffered image.   *   * The returned image will be formatted according to the   * currently-preferred image type specifier.   *   * Installed read progress listeners, update progress listeners and   * warning listeners will be notified of read progress, changes in   * sample sets and warnings respectively.   *   * @param the index of the image frame to read   *   * @return a buffered 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 BufferedImage read (int imageIndex)    throws IOException  {    return read (imageIndex, null);  }  /**   * Read the given frame all at once, using the given image read   * parameters, and return an IIOImage.  The IIOImage will contain a   * buffered image as returned by getDestination.   *   * Installed read progress listeners, update progress listeners and   * warning listeners will be notified of read progress, changes in   * sample sets and warnings respectively.   *   * The source and destination band settings are checked with a call   * to checkReadParamBandSettings.   *   * @param the index of the image frame to read   * @param the image read parameters   *   * @return an IIOImage   *   * @exception IllegalStateException if input has not been set   * @exception IndexOutOfBoundsException if the frame index is   * out-of-bounds   * @exception IllegalArgumentException if param.getSourceBands() and   * param.getDestinationBands() are incompatible   * @exception IllegalArgumentException if either the source or   * destination image regions are empty   * @exception IOException if a read error occurs   */  public IIOImage readAll (int imageIndex,			   ImageReadParam param)    throws IOException  {    checkReadParamBandSettings (param,                                param.getSourceBands().length,                                param.getDestinationBands().length);    List l = new ArrayList ();    for (int i = 0; i < getNumThumbnails (imageIndex); i++)      l.add (readThumbnail(imageIndex, i));    return new IIOImage (getDestination(param, getImageTypes(imageIndex),                                        getWidth(imageIndex),                                        getHeight(imageIndex)),                         l,                         getImageMetadata (imageIndex));  }  /**   * Read all image frames all at once, using the given image read   * parameters iterator, and return an iterator over a collection of   * IIOImages.  Each IIOImage in the collection will contain a   * buffered image as returned by getDestination.   *   * Installed read progress listeners, update progress listeners and   * warning listeners will be notified of read progress, changes in   * sample sets and warnings respectively.   *   * Each set of source and destination band settings are checked with   * a call to checkReadParamBandSettings.   *   * @param an iterator over the image read parameters   *   * @return an IIOImage   *   * @exception IllegalStateException if input has not been set   * @exception IllegalArgumentException if a non-ImageReadParam is   * found in params   * @exception IllegalArgumentException if param.getSourceBands() and   * param.getDestinationBands() are incompatible   * @exception IllegalArgumentException if either the source or   * destination image regions are empty   * @exception IOException if a read error occurs   */  public Iterator readAll (Iterator params)    throws IOException  {    List l = new ArrayList ();    int index = 0;    while (params.hasNext())      {        if (params != null && ! (params instanceof ImageReadParam))          throw new IllegalArgumentException ("non-ImageReadParam found");        l.add (readAll(index++, (ImageReadParam) params.next ()));      }    return l.iterator();  }  /**   * Read a rendered image.  This is a more general counterpart to   * read (int, ImageReadParam).  All image data may not be read   * before this method returns and so listeners will not necessarily   * be notified.   *   * @param the index of the image frame to read   * @param the image read parameters   *   * @return a rendered image   *   * @exception IllegalStateException if input is null   * @exception IndexOutOfBoundsException if the frame index is   * out-of-bounds   * @exception IllegalArgumentException if param.getSourceBands() and   * param.getDestinationBands() are incompatible   * @exception IllegalArgumentException if either the source or   * destination image regions are empty   * @exception IOException if a read error occurs   */  public RenderedImage readAsRenderedImage (int imageIndex,					    ImageReadParam param)    throws IOException  {    return read (imageIndex, param);  }  /**   * Read the given tile into a buffered image.  If the tile   * coordinates are out-of-bounds an exception is thrown.  If the   * image is not tiled then the coordinates 0, 0 are expected and the   * entire image will be read.   *   * @param imageIndex the frame index   * @param tileX the horizontal tile coordinate   * @param tileY the vertical tile coordinate   *   * @return the contents of the tile as a buffered image   *   * @exception IllegalStateException if input is null   * @exception IndexOutOfBoundsException if the frame index is   * out-of-bounds   * @exception IllegalArgumentException if the tile coordinates are   * out-of-bounds   * @exception IOException if a read error occurs   */  public BufferedImage readTile (int imageIndex, int tileX, int tileY)    throws IOException  {    if (tileX != 0 || tileY != 0)      throw new IllegalArgumentException ("tileX not 0 or tileY not 0");    return read (imageIndex);  }  /**   * Read the given tile into a raster containing the raw image data.   * If the tile coordinates are out-of-bounds an exception is thrown.   * If the image is not tiled then the coordinates 0, 0 are expected   * and the entire image will be read.   *   * @param imageIndex the frame index   * @param tileX the horizontal tile coordinate   * @param tileY the vertical tile coordinate   *   * @return the contents of the tile as a raster   *   * @exception UnsupportedOperationException if rasters are not   * supported   * @exception IllegalStateException if input is null   * @exception IndexOutOfBoundsException if the frame index is   * out-of-bounds   * @exception IllegalArgumentException if the tile coordinates are   * out-of-bounds   * @exception IOException if a read error occurs   */  public Raster readTileRaster (int imageIndex, int tileX, int tileY)    throws IOException  {    if (!canReadRaster())      throw new UnsupportedOperationException ("cannot read rasters");    if (tileX != 0 || tileY != 0)      throw new IllegalArgumentException ("tileX not 0 or tileY not 0");    return readRaster (imageIndex, null);  }  /**   * Reset this reader's internal state.   */  public void reset ()  {    setInput (null, false);    setLocale (null);    removeAllIIOReadUpdateListeners ();    removeAllIIOReadWarningListeners ();    removeAllIIOReadProgressListeners ();    clearAbortRequest ();  }}

⌨️ 快捷键说明

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