Package java.awt.image

Examples of java.awt.image.WritableRaster


        }

        // Loop over all in-bound tiles, find ones that have been computed
        for (int j = tyMin; j <= tyMax; j++) {
            for (int i = txMin; i <= txMax; i++) {
                WritableRaster t;
                if ((t = tiles[i - minTileX][j - minTileY]) != null &&
                    !isTileLocked(i, j)) {
                    Rectangle rect = getTileRect(i, j).intersection(overlap);
                    if(!rect.isEmpty()) {
                        if (roiShape != null) {
View Full Code Here


                // Create the tile using the ancestor SampleModel.
                tiles[tileX - minTileX][tileY - minTileY] =
                    createWritableRaster(ancestorSampleModel,
                                         new Point(tileXToX(tileX),
                                                   tileYToY(tileY)));
                WritableRaster tile = tiles[tileX - minTileX][tileY - minTileY];

                // If a source is available try to set the tile's data.
                if(src != null) {
                    // Get the bounds of the tile's support.
                    Rectangle tileRect = getTileRect(tileX, tileY);

                    // Determine the intersection of the tile and the overlap.
                    Rectangle rect = overlapBounds.intersection(tileRect);

                    // Bail if this doesn't intersect the effective overlap.
                    if(rect.isEmpty()) {
                        return;
                    }

                    // If a source ROI is present, use it.
                    if(srcROI != null) {
                        // Attempt to get the ROI as a Shape.
                        Shape roiShape = srcROI.getAsShape();

                        if (roiShape != null) {
                            // Determine the area of overlap.
                            Area a = new Area(rect);
                            a.intersect(new Area(roiShape));

                            if(!a.isEmpty()) {
                                // If the area is non-empty overlay the pixels.
                                overlayPixels(tile, src, a);
                            }
                        } else {
                            int[][] bitmask =
                                srcROI.getAsBitmask(rect.x, rect.y,
                                                    rect.width, rect.height,
                                                    null);

                            overlayPixels(tile, src, rect, bitmask);
                        }
                    } else {
                        // If the intersection equals the tile area, copy data into
                        // the entire tile.  If the tile straddles the edge of the
                        // source, copy only into the intersection.
                        if(!rect.isEmpty()) {
                            if(bandList == null && rect.equals(tileRect)) {
                                // The current image has the same bands in the
                                // same order as its ancestor TiledImage and
                                // the requested tile is completely within "src".
                                if (tileRect.equals(tile.getBounds()))
                                    src.copyData(tile);
                                else
                                    src.copyData(
                                        tile.createWritableChild(rect.x, rect.y,
                                                                 rect.width,
                                                                 rect.height,
                                                                 rect.x,
                                                                 rect.y,
                                                                 null));
View Full Code Here

        if(bandList == null) {
            return tiles[tileX - minTileX][tileY - minTileY];
        }

        // For sub-banded image return appropriate band subset.
        WritableRaster wr = tiles[tileX - minTileX][tileY - minTileY];

        return wr.createWritableChild(wr.getMinX(), wr.getMinY(),
                                      wr.getWidth(), wr.getHeight(),
                                      wr.getMinX(), wr.getMinY(),
                                      bandList);
    }
View Full Code Here

        int txMax = XToTileX(rBounds.x + rBounds.width - 1);
        int tyMax = YToTileY(rBounds.y + rBounds.height - 1);

        for(int ty = tyMin; ty <= tyMax; ty++) {
            for(int tx = txMin; tx <= txMax; tx++) {
                WritableRaster wr = getWritableTile(tx, ty);
                if(wr != null) {
                    // XXX bpb 02/04/1999
                    // All this checking shouldn't be necessary except
                    // that it doesn't look as if WritableRaster.setRect()
                    // correctly accounts for cases wherein the parameter
                    // Raster is not contained in the target WritableRaster.
                    Rectangle tileRect = getTileRect(tx, ty);
                    if(tileRect.contains(rBounds)) {
                        JDKWorkarounds.setRect(wr, r, 0, 0);
                    } else {
                        Rectangle xsect = rBounds.intersection(tileRect);
                        Raster rChild =
                            r.createChild(xsect.x, xsect.y,
                                          xsect.width, xsect.height,
                                          xsect.x, xsect.y, null);
                        WritableRaster wChild =
                            wr.createWritableChild(xsect.x, xsect.y,
                                                   xsect.width, xsect.height,
                                                   xsect.x, xsect.y, null);
                        JDKWorkarounds.setRect(wChild, rChild, 0, 0);
                    }
View Full Code Here

        int numRects = rectList.size();

        for(int ty = tyMin; ty <= tyMax; ty++) {
            for(int tx = txMin; tx <= txMax; tx++) {
                WritableRaster wr = getWritableTile(tx, ty);
                if(wr != null) {
                    Rectangle tileRect = getTileRect(tx, ty);
                    for(int i = 0; i < numRects; i++) {
                        Rectangle rect = (Rectangle)rectList.get(i);
                        rect = rect.intersection(tileRect);
                        // XXX: Should the if-block below be split as in
                        // set(RenderedImage, ROI) above?
                        if(!rect.isEmpty()) {
                            Raster rChild =
                                r.createChild(rect.x, rect.y,
                                              rect.width, rect.height,
                                              rect.x, rect.y, null);
                            WritableRaster wChild =
                                wr.createWritableChild(rect.x, rect.y,
                                                       rect.width, rect.height,
                                                       rect.x, rect.y, null);
                            JDKWorkarounds.setRect(wChild, rChild, 0, 0);
                        }
View Full Code Here

     * @param s The value to which to set the sample.
     */
    public void setSample(int x, int y, int b, int s) {
        int tileX = XToTileX(x);
        int tileY = YToTileY(y);
        WritableRaster t = getWritableTile(tileX, tileY);
        if(t != null) {
            t.setSample(x, y, b, s);
        }
        releaseWritableTile(tileX, tileY);
    }
View Full Code Here

     * @param s The value to which to set the sample.
     */
    public void setSample(int x, int y, int b, float s) {
        int tileX = XToTileX(x);
        int tileY = YToTileY(y);
        WritableRaster t = getWritableTile(tileX, tileY);
        if(t != null) {
            t.setSample(x, y, b, s);
        }
        releaseWritableTile(tileX, tileY);
    }
View Full Code Here

     * @param s The value to which to set the sample.
     */
    public void setSample(int x, int y, int b, double s) {
        int tileX = XToTileX(x);
        int tileY = YToTileY(y);
        WritableRaster t = getWritableTile(tileX, tileY);
        if(t != null) {
            t.setSample(x, y, b, s);
        }
        releaseWritableTile(tileX, tileY);
    }
View Full Code Here

  // X and Y coordinate of the pixel pixel of the tile.
  int orgX = tileXToX(tileX);
  int orgY = tileYToY(tileY);

  // Create a new WritableRaster to represent this tile.
  WritableRaster dest = createWritableRaster(sampleModel,
                                                   new Point(orgX, orgY));

  Rectangle rect = new Rectangle(orgX, orgY, tileWidth, tileHeight);

        // Clip dest rectangle against the part of the destination
View Full Code Here

    }

    /** Computes the pixel values for the specified tile. */
    public Raster computeTile(int tileX, int tileY) {
        // Create a new Raster.
        WritableRaster dest = createTile(tileX, tileY);

        // Extend the data.
        getSourceImage(0).copyExtendedData(dest, extender);

        return dest;
View Full Code Here

TOP

Related Classes of java.awt.image.WritableRaster

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.