Java 类java.awt.image.WritableRenderedImage 实例源码

项目:rastertheque    文件:SnapshotImage.java   
/**
 * Constructs a <code>SnapshotImage</code> from a <code>PlanarImage</code>
 * source.
 *
 * @param source a <code>PlanarImage</code> source.
 * @throws IllegalArgumentException if source is null.
 */
public SnapshotImage(PlanarImage source) {
    super(new ImageLayout(source), null, null);

    // Record the source image
    this.source = source;
    //  Set image parameters to match the source

    //  Determine which tiles of the source image are writable
    if (source instanceof WritableRenderedImage) {
        WritableRenderedImage wri = (WritableRenderedImage)source;
        wri.addTileObserver(this);

        Point[] pts = wri.getWritableTileIndices();
        if (pts != null) {
            int num = pts.length;
            for (int i = 0; i < num; i++) {
                //  Add these tiles to the active list
                Point p = pts[i];
                activeTiles.add(new Point(p.x, p.y));
           }
        }
    }
}
项目:rastertheque    文件:SnapshotImage.java   
/**
 * Receives the information that a tile is either about to become
 * writable, or is about to become no longer writable.
 *
 * @param source the <code>WritableRenderedImage</code> for which we
 *               are an observer.
 * @param tileX the X index of the tile.
 * @param tileY the Y index of the tile.
 * @param willBeWritable true if the tile is becoming writable.
 */
public void tileUpdate(WritableRenderedImage source,
                       int tileX, int tileY,
                       boolean willBeWritable) {
    if (willBeWritable) {
        // If the last Snapshot doesn't have the tile, copy it
        if ((tail != null) && (!tail.hasTile(tileX, tileY))) {
            tail.addTile(createTileCopy(tileX, tileY), tileX, tileY);
        }
        // Add the tile to the active list
        activeTiles.add(new Point(tileX, tileY));
    } else {
        // Remove the tile from the active list
        activeTiles.remove(new Point(tileX, tileY));
    }
}
项目:soil_sealing    文件:JiffleScriptListProcess.java   
/**
 * Private method used for executing the script operation on an input image with the selected GridGeometry2D.
 * 
 * @param input RenderedImage to process
 * @param jb jiffleBuilder object with the script to execute
 * @param destGridGeometry GridGeometry object associated to the output image
 * @return img output image generated from the script
 * @throws JiffleException
 */
private RenderedImage jiffleProcessExecution(RenderedImage input, JiffleBuilder jb,
        GridGeometry2D destGridGeometry) throws JiffleException {

    // Setting of the source
    jb.source("image", input, null, false);

    // Now we specify the tile dimensions of the final image
    int tileWidth = input.getTileWidth();
    int tileHeight = input.getTileHeight();
    // Creation of a SampleModel associated with the final image
    SampleModel sm = RasterFactory.createPixelInterleavedSampleModel(DataBuffer.TYPE_DOUBLE,
            tileWidth, tileHeight, 1);
    // Selection of the GridEnvelope associated to the input coverage
    final GridEnvelope2D gr2d = destGridGeometry.getGridRange2D();
    // Final image creation
    final WritableRenderedImage img = new TiledImage(gr2d.x, gr2d.y, gr2d.width, gr2d.height,
            0, 0, sm, PlanarImage.createColorModel(sm));
    // Setting of the final image
    jb.dest("dest", img);

    // Finally we run the script and retrieve the resulting image.
    jb.run();

    return img;
}
项目:rastertheque    文件:SnapshotImage.java   
/**
 * Creates a snapshot of this image.  This snapshot may be used
 * indefinitely, and will always appear to have the pixel data that
 * this image has currently.  The snapshot is semantically a copy
 * of this image but may be implemented in a more efficient manner.
 * Multiple snapshots taken at different times may share tiles that
 * have not changed, and tiles that are currently static in this
 * image's source do not need to be copied at all.
 *
 * @return a <code>PlanarImage</code> snapshot.
 */
public PlanarImage createSnapshot() {
    if (source instanceof WritableRenderedImage) {
        // Create a new Snapshot
        Snapshot snap = new Snapshot(this);

        // For each active tile:
        Iterator iter = activeTiles.iterator();
        while (iter.hasNext()) {
            Point p = (Point)iter.next();

            // Make a copy and store it in the Snapshot
            Raster tile = createTileCopy(p.x, p.y);
            snap.addTile(tile, p.x, p.y);
        }

        // Add the new Snapshot to the list of snapshots
        if (tail == null) {
            tail = snap;
        } else {
            tail.setNext(snap);
            snap.setPrev(tail);
            tail = snap;
        }

        // Create a proxy and return it
        return new SnapshotProxy(snap);
    } else {
        return source;
    }
}
项目:rastertheque    文件:PlanarImage.java   
/**
    * Creates a snapshot, that is, a virtual copy of the image's
    * current contents.  If the image is not a
    * <code>WritableRenderedImage</code>, it is returned unchanged.
    * Otherwise, a <code>SnapshotImage</code> is created and the
    * result of calling its <code>createSnapshot()</code> is
    * returned.
    *
    * @return A <code>PlanarImage</code> with immutable contents.
    */
   public PlanarImage createSnapshot() {
if (this instanceof WritableRenderedImage) {
           if (snapshot == null) {
               synchronized (this) {
                   snapshot = new SnapshotImage(this);
               }
           }
           return snapshot.createSnapshot();

} else {
           return this;
       }
   }
项目:rastertheque    文件:RookIterFactory.java   
/**
 * Constructs and returns an instance of WritableRookIter suitable for
 * iterating over the given bounding rectangle within the given
 * WritableRenderedImage source.  If the bounds parameter is null,
 * the entire image will be used.
 *
 * @param im a WritableRenderedImage source.
 * @param bounds the bounding Rectangle for the iterator, or null.
 * @return a WritableRookIter allowing read/write access to the source.
 */
public static WritableRookIter createWritable(WritableRenderedImage im,
                                              Rectangle bounds) {
    if (bounds == null) {
        bounds = new Rectangle(im.getMinX(), im.getMinY(),
                               im.getWidth(), im.getHeight());
    }

    SampleModel sm = im.getSampleModel();
    if (sm instanceof ComponentSampleModel) {
        switch (sm.getDataType()) {
        case DataBuffer.TYPE_BYTE:
            // return new WritableRookIterCSMByte(im, bounds);
        case DataBuffer.TYPE_SHORT:
            // return new WritableRookIterCSMShort(im, bounds);
        case DataBuffer.TYPE_USHORT:
            // return new WritableRookIterCSMUShort(im, bounds);
        case DataBuffer.TYPE_INT:
            // return new WritableRookIterCSMInt(im, bounds);
        case DataBuffer.TYPE_FLOAT:
            // return new WritableRookIterCSMFloat(im, bounds);
        case DataBuffer.TYPE_DOUBLE:
            // return new WritableRookIterCSMDouble(im, bounds);
        }
    }

    return new WritableRookIterFallback(im, bounds);
}
项目:rastertheque    文件:RectIterFactory.java   
/**
   * Constructs and returns an instance of WritableRectIter suitable for
   * iterating over the given bounding rectangle within the given
   * WritableRenderedImage source.  If the bounds parameter is null,
   * the entire image will be used.
   *
   * @param im a WritableRenderedImage source.
   * @param bounds the bounding Rectangle for the iterator, or null.
   * @return a WritableRectIter allowing read/write access to the source.
   */
  public static WritableRectIter createWritable(WritableRenderedImage im,
                                                Rectangle bounds) {
      if (bounds == null) {
          bounds = new Rectangle(im.getMinX(), im.getMinY(),
                                 im.getWidth(), im.getHeight());
      }

      SampleModel sm = im.getSampleModel();
      if (sm instanceof ComponentSampleModel) {
          switch (sm.getDataType()) {
          case DataBuffer.TYPE_BYTE:
              return new WritableRectIterCSMByte(im, bounds);
          case DataBuffer.TYPE_SHORT:
              // return new WritableRectIterCSMShort(im, bounds);
break;
          case DataBuffer.TYPE_USHORT:
              // return new WritableRectIterCSMUShort(im, bounds);
break;
          case DataBuffer.TYPE_INT:
              // return new WritableRectIterCSMInt(im, bounds);
break;
          case DataBuffer.TYPE_FLOAT:
              return new WritableRectIterCSMFloat(im, bounds);
          case DataBuffer.TYPE_DOUBLE:
              // return new WritableRectIterCSMDouble(im, bounds);
break;
          }
      }

      return new WritableRectIterFallback(im, bounds);
  }
项目:rastertheque    文件:RandomIterFactory.java   
/**
 * Constructs and returns an instance of WritableRandomIter
 * suitable for iterating over the given bounding rectangle within
 * the given WritableRenderedImage source.  If the bounds
 * parameter is null, the entire image will be used.
 *
 * @param im a WritableRenderedImage source.
 * @param bounds the bounding Rectangle for the iterator, or null.
 * @return a WritableRandomIter allowing read/write access to the source.
 */
public static WritableRandomIter createWritable(WritableRenderedImage im,
                                                Rectangle bounds) {
    if (bounds == null) {
        bounds = new Rectangle(im.getMinX(), im.getMinY(),
                               im.getWidth(), im.getHeight());
    }

    SampleModel sm = im.getSampleModel();
    if (sm instanceof ComponentSampleModel) {
        switch (sm.getDataType()) {
        case DataBuffer.TYPE_BYTE:
            // return new WritableRandomIterCSMByte(im, bounds);
        case DataBuffer.TYPE_SHORT:
            // return new WritableRandomIterCSMShort(im, bounds);
        case DataBuffer.TYPE_USHORT:
            // return new WritableRandomIterCSMUShort(im, bounds);
        case DataBuffer.TYPE_INT:
            // return new WritableRandomIterCSMInt(im, bounds);
        case DataBuffer.TYPE_FLOAT:
            // return new WritableRandomIterCSMFloat(im, bounds);
        case DataBuffer.TYPE_DOUBLE:
            // return new WritableRandomIterCSMDouble(im, bounds);
        }
    }

    return new WritableRandomIterFallback(im, bounds);
}
项目:NK-VirtualGlobe    文件:SAISFImage.java   
/**
 * Fetch the Java representation of the underlying image from these pixels.
 * This is the same copy that the browser uses to generate texture
 * information from.
 *
 * @return The image reference representing the current state
 */
public WritableRenderedImage getImage() {
    checkAccess(false);

    int width = getWidth( );
    int height = getHeight( );
    int components = getComponents( );
    int pixels[] = new int[width*height];
    getPixels( pixels );

    return( SFImageUtils.convertDataToRenderedImage( width, height, components, pixels ) );
}
项目:NK-VirtualGlobe    文件:SFImageWrapper.java   
/**
 * Fetch the Java representation of the underlying image from these pixels.
 * This is the same copy that the browser uses to generate texture
 * information from.
 *
 * @return The image reference representing the current state
 */
public WritableRenderedImage getImage() {
    checkReadAccess();

    int width = getWidth( );
    int height = getHeight( );
    int components = getComponents( );
    int pixels[] = new int[width*height];
    getPixels( pixels );

    return( SFImageUtils.convertDataToRenderedImage( width, height, components, pixels ) );
}
项目:rastertheque    文件:WritableRandomIterFallback.java   
public WritableRandomIterFallback(WritableRenderedImage im,
                                  Rectangle bounds) {
    super(im, bounds);
    this.wim = im;
}
项目:rastertheque    文件:WritableRandomIterCSMShort.java   
public WritableRandomIterCSMShort(WritableRenderedImage im,
                                  Rectangle bounds) {
    super(im, bounds);
}
项目:rastertheque    文件:WritableRandomIterCSMByte.java   
public WritableRandomIterCSMByte(WritableRenderedImage im,
                                 Rectangle bounds) {
    super(im, bounds);
}
项目:rastertheque    文件:WritableRandomIterCSMInt.java   
public WritableRandomIterCSMInt(WritableRenderedImage im,
                                Rectangle bounds) {
    super(im, bounds);
}
项目:rastertheque    文件:WritableRandomIterCSMDouble.java   
public WritableRandomIterCSMDouble(WritableRenderedImage im,
                                   Rectangle bounds) {
    super(im, bounds);
}
项目:rastertheque    文件:WritableRectIterFallback.java   
public WritableRectIterFallback(WritableRenderedImage im,
                                Rectangle bounds) {
    super(im, bounds);
    this.wim = im;
}
项目:rastertheque    文件:WritableRandomIterCSMUShort.java   
public WritableRandomIterCSMUShort(WritableRenderedImage im,
                                   Rectangle bounds) {
    super(im, bounds);
}
项目:rastertheque    文件:WritableRookIterFallback.java   
public WritableRookIterFallback(WritableRenderedImage im,
                                Rectangle bounds) {
    super(im, bounds);
}
项目:rastertheque    文件:WritableRandomIterCSMFloat.java   
public WritableRandomIterCSMFloat(WritableRenderedImage im,
                                  Rectangle bounds) {
    super(im, bounds);
}
项目:rastertheque    文件:PlanarImage.java   
/**
    * Wraps an arbitrary <code>RenderedImage</code> to produce a
    * <code>PlanarImage</code>.  <code>PlanarImage</code> adds
    * various properties to an image, such as source and sink vectors
    * and the ability to produce snapshots, that are necessary for
    * JAI.
    *
    * <p> If the image is already a <code>PlanarImage</code>, it is
    * simply returned unchanged.  Otherwise, the image is wrapped in
    * a <code>RenderedImageAdapter</code> or
    * <code>WritableRenderedImageAdapter</code> as appropriate.
    *
    * @param image  The <code>RenderedImage</code> to be converted into
    *        a <code>PlanarImage</code>.
    *
    * @return A <code>PlanarImage</code> containing <code>image</code>'s
    *         pixel data.
    *
    * @throws IllegalArgumentException  If <code>image</code> is
    *         <code>null</code>.
    */
   public static PlanarImage wrapRenderedImage(RenderedImage image) {
       if (image == null) {
           throw new IllegalArgumentException(JaiI18N.getString("Generic0"));
       }

if (image instanceof PlanarImage) {
    return (PlanarImage)image;
} else if (image instanceof WritableRenderedImage) {
    return new WritableRenderedImageAdapter(
                          (WritableRenderedImage)image);
} else {
    return new RenderedImageAdapter(image);
       }
   }
项目:NK-VirtualGlobe    文件:MFImageWrapper.java   
/**
 * Fetch the Java representation of the underlying image from these pixels.
 * This is the same copy that the browser uses to generate texture
 * information from.
 *
 * @param imgIndex The index of the image in the array
 * @return The image reference representing the current state
 */
public WritableRenderedImage getImage(int imgIndex) {
    // Formula:
    //   Copy all but the last line of getPixel
    //   Invoke the magic code to convert from SFImage to WritableRenderedImage
    throw new RuntimeException("Not yet implemented");
}
项目:rastertheque    文件:WritableRenderedImageAdapter.java   
/**
 * Constructs a <code>WritableRenderedImageAdapter</code>.
 *
 * @param im A <code>WritableRenderedImage</code> to be `wrapped'
 * as a <code>PlanarImage</code>.
 * @throws <code>IllegalArgumentException</code> if <code>im</code> is
 *         <code>null</code>.
 */
public WritableRenderedImageAdapter(WritableRenderedImage im) {
    super(im);
    theWritableImage = im;
}
项目:rastertheque    文件:RookIterFactory.java   
/**
 * Constructs and returns an instance of WritableRookIter suitable for
 * iterating over the given bounding rectangle within the given
 * WritableRaster source.  If the bounds parameter is null,
 * the entire Raster will be used.
 *
 * @param ras a WritableRaster source.
 * @param bounds the bounding Rectangle for the iterator, or null.
 * @return a WritableRookIter allowing read/write access to the source.
 */
public static WritableRookIter createWritable(WritableRaster ras,
                                              Rectangle bounds) {
    WritableRenderedImage im = new WrapperWRI(ras);
    return createWritable(im, bounds);
}
项目:rastertheque    文件:RectIterFactory.java   
/**
 * Constructs and returns an instance of WritableRectIter suitable for
 * iterating over the given bounding rectangle within the given
 * WritableRaster source.  If the bounds parameter is null,
 * the entire Raster will be used.
 *
 * @param ras a WritableRaster source.
 * @param bounds the bounding Rectangle for the iterator, or null.
 * @return a WritableRectIter allowing read/write access to the source.
 */
public static WritableRectIter createWritable(WritableRaster ras,
                                              Rectangle bounds) {
    WritableRenderedImage im = new WrapperWRI(ras);
    return createWritable(im, bounds);
}
项目:rastertheque    文件:RandomIterFactory.java   
/**
 * Constructs and returns an instance of WritableRandomIter
 * suitable for iterating over the given bounding rectangle within
 * the given WritableRaster source.  If the bounds parameter is
 * null, the entire Raster will be used.
 *
 * @param ras a WritableRaster source.
 * @param bounds the bounding Rectangle for the iterator, or null.
 * @return a WritableRandomIter allowing read/write access to the source.
 */
public static WritableRandomIter createWritable(WritableRaster ras,
                                                Rectangle bounds) {
    WritableRenderedImage im = new WrapperWRI(ras);
    return createWritable(im, bounds);
}
项目:NK-VirtualGlobe    文件:SFImage.java   
/**
 * Fetch the Java representation of the underlying image from these pixels.
 * This is the same copy that the browser uses to generate texture
 * information from.
 *
 * @return The image reference representing the current state
 */
public WritableRenderedImage getImage();
项目:NK-VirtualGlobe    文件:MFImage.java   
/**
 * Fetch the Java representation of the underlying image from these pixels.
 * This is the same copy that the browser uses to generate texture
 * information from.
 *
 * @param imgIndex The index of the image in the array
 * @return The image reference representing the current state
 */
public WritableRenderedImage getImage(int imgIndex);
项目:NK-VirtualGlobe    文件:SAIMFImage.java   
/**
 * Fetch the Java representation of the underlying image from these pixels.
 * This is the same copy that the browser uses to generate texture
 * information from.
 *
 * @param imgIndex The index of the image in the array
 * @return The image reference representing the current state
 */
public WritableRenderedImage getImage(int imgIndex) {
    checkAccess(false);

    return null;
}