java.awt.image.Raster#getMinX()源码实例Demo

下面列出了java.awt.image.Raster#getMinX() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-jdk8u   文件: ByteInterleavedRaster.java
/**
 * Stores the Raster data at the specified location.
 * An ArrayIndexOutOfBounds exception will be thrown at runtime
 * if the pixel coordinates are out of bounds.
 * @param x          The X coordinate of the pixel location.
 * @param y          The Y coordinate of the pixel location.
 * @param inRaster   Raster of data to place at x,y location.
 */
public void setDataElements(int x, int y, Raster inRaster) {
    int srcOffX = inRaster.getMinX();
    int srcOffY = inRaster.getMinY();
    int dstOffX = x + srcOffX;
    int dstOffY = y + srcOffY;
    int width  = inRaster.getWidth();
    int height = inRaster.getHeight();
    if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
        (dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
        throw new ArrayIndexOutOfBoundsException
            ("Coordinate out of bounds!");
    }

    setDataElements(dstOffX, dstOffY, srcOffX, srcOffY,
                    width, height, inRaster);
}
 
源代码2 项目: hottub   文件: ByteBandedRaster.java
/**
     * Stores the Raster data at the specified location.
     * @param dstX The absolute X coordinate of the destination pixel
     * that will receive a copy of the upper-left pixel of the
     * inRaster
     * @param dstY The absolute Y coordinate of the destination pixel
     * that will receive a copy of the upper-left pixel of the
     * inRaster
     * @param width      The number of pixels to store horizontally
     * @param height     The number of pixels to store vertically
     * @param inRaster   Raster of data to place at x,y location.
     */
    private void setDataElements(int dstX, int dstY,
                                 int width, int height,
                                 Raster inRaster) {
        // Assume bounds checking has been performed previously
        if (width <= 0 || height <= 0) {
            return;
        }

        int srcOffX = inRaster.getMinX();
        int srcOffY = inRaster.getMinY();
        Object tdata = null;

//      // REMIND: Do something faster!
//      if (inRaster instanceof ByteBandedRaster) {
//      }

        for (int startY=0; startY < height; startY++) {
            // Grab one scanline at a time
            tdata = inRaster.getDataElements(srcOffX, srcOffY+startY,
                                             width, 1, tdata);
            setDataElements(dstX, dstY+startY, width, 1, tdata);
        }
    }
 
源代码3 项目: TencentKona-8   文件: ByteInterleavedRaster.java
public void setRect(int dx, int dy, Raster srcRaster) {
    if (!(srcRaster instanceof ByteInterleavedRaster)) {
        super.setRect(dx, dy, srcRaster);
        return;
    }

    int width  = srcRaster.getWidth();
    int height = srcRaster.getHeight();
    int srcOffX = srcRaster.getMinX();
    int srcOffY = srcRaster.getMinY();
    int dstOffX = dx+srcOffX;
    int dstOffY = dy+srcOffY;

    // Clip to this raster
    if (dstOffX < this.minX) {
        int skipX = minX - dstOffX;
        width -= skipX;
        srcOffX += skipX;
        dstOffX = this.minX;
    }
    if (dstOffY < this.minY) {
        int skipY = this.minY - dstOffY;
        height -= skipY;
        srcOffY += skipY;
        dstOffY = this.minY;
    }
    if (dstOffX+width > this.maxX) {
        width = this.maxX - dstOffX;
    }
    if (dstOffY+height > this.maxY) {
        height = this.maxY - dstOffY;
    }

    setDataElements(dstOffX, dstOffY,
                    srcOffX, srcOffY,
                    width, height, srcRaster);
}
 
源代码4 项目: jdk8u_jdk   文件: IntegerComponentRaster.java
/**
 * Stores the Raster data at the specified location.
 * The transferType of the inputRaster must match this raster.
 * An ArrayIndexOutOfBoundsException will be thrown at runtime
 * if the pixel coordinates are out of bounds.
 * @param x          The X coordinate of the pixel location.
 * @param y          The Y coordinate of the pixel location.
 * @param inRaster   Raster of data to place at x,y location.
 */
public void setDataElements(int x, int y, Raster inRaster) {
    int dstOffX = x + inRaster.getMinX();
    int dstOffY = y + inRaster.getMinY();
    int width  = inRaster.getWidth();
    int height = inRaster.getHeight();
    if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
        (dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
        throw new ArrayIndexOutOfBoundsException
            ("Coordinate out of bounds!");
    }
    setDataElements(dstOffX, dstOffY, width, height, inRaster);
}
 
源代码5 项目: openjdk-jdk8u   文件: ByteBandedRaster.java
/**
 * Stores the Raster data at the specified location.
 * An ArrayIndexOutOfBounds exception will be thrown at runtime
 * if the pixel coordinate is out of bounds.
 * @param x          The X coordinate of the pixel location.
 * @param y          The Y coordinate of the pixel location.
 * @param inRaster   Raster of data to place at x,y location.
 */
public void setDataElements(int x, int y, Raster inRaster) {
    int dstOffX = inRaster.getMinX() + x;
    int dstOffY = inRaster.getMinY() + y;
    int width  = inRaster.getWidth();
    int height = inRaster.getHeight();
    if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
        (dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
        throw new ArrayIndexOutOfBoundsException
            ("Coordinate out of bounds!");
    }

    setDataElements(dstOffX, dstOffY, width, height, inRaster);
}
 
源代码6 项目: openjdk-jdk8u   文件: ByteInterleavedRaster.java
public void setRect(int dx, int dy, Raster srcRaster) {
    if (!(srcRaster instanceof ByteInterleavedRaster)) {
        super.setRect(dx, dy, srcRaster);
        return;
    }

    int width  = srcRaster.getWidth();
    int height = srcRaster.getHeight();
    int srcOffX = srcRaster.getMinX();
    int srcOffY = srcRaster.getMinY();
    int dstOffX = dx+srcOffX;
    int dstOffY = dy+srcOffY;

    // Clip to this raster
    if (dstOffX < this.minX) {
        int skipX = minX - dstOffX;
        width -= skipX;
        srcOffX += skipX;
        dstOffX = this.minX;
    }
    if (dstOffY < this.minY) {
        int skipY = this.minY - dstOffY;
        height -= skipY;
        srcOffY += skipY;
        dstOffY = this.minY;
    }
    if (dstOffX+width > this.maxX) {
        width = this.maxX - dstOffX;
    }
    if (dstOffY+height > this.maxY) {
        height = this.maxY - dstOffY;
    }

    setDataElements(dstOffX, dstOffY,
                    srcOffX, srcOffY,
                    width, height, srcRaster);
}
 
源代码7 项目: hottub   文件: IntegerInterleavedRaster.java
/**
 * Stores the Raster data at the specified location.
 * The transferType of the inputRaster must match this raster.
 * An ArrayIndexOutOfBoundsException will be thrown at runtime
 * if the pixel coordinates are out of bounds.
 * @param x          The X coordinate of the pixel location.
 * @param y          The Y coordinate of the pixel location.
 * @param inRaster   Raster of data to place at x,y location.
 */
public void setDataElements(int x, int y, Raster inRaster) {
    int dstOffX = x + inRaster.getMinX();
    int dstOffY = y + inRaster.getMinY();
    int width  = inRaster.getWidth();
    int height = inRaster.getHeight();
    if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
        (dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
        throw new ArrayIndexOutOfBoundsException
            ("Coordinate out of bounds!");
    }

    setDataElements(dstOffX, dstOffY, width, height, inRaster);
}
 
源代码8 项目: TencentKona-8   文件: ShortInterleavedRaster.java
/**
 * Stores the Raster data at the specified location.
 * An ArrayIndexOutOfBounds exception will be thrown at runtime
 * if the pixel coordinates are out of bounds.
 * @param x          The X coordinate of the pixel location.
 * @param y          The Y coordinate of the pixel location.
 * @param inRaster   Raster of data to place at x,y location.
 */
public void setDataElements(int x, int y, Raster inRaster) {
    int dstOffX = x + inRaster.getMinX();
    int dstOffY = y + inRaster.getMinY();
    int width  = inRaster.getWidth();
    int height = inRaster.getHeight();
    if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
        (dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
        throw new ArrayIndexOutOfBoundsException
            ("Coordinate out of bounds!");
    }

    setDataElements(dstOffX, dstOffY, width, height, inRaster);
}
 
源代码9 项目: jdk8u_jdk   文件: ByteBandedRaster.java
/**
 * Stores the Raster data at the specified location.
 * An ArrayIndexOutOfBounds exception will be thrown at runtime
 * if the pixel coordinate is out of bounds.
 * @param x          The X coordinate of the pixel location.
 * @param y          The Y coordinate of the pixel location.
 * @param inRaster   Raster of data to place at x,y location.
 */
public void setDataElements(int x, int y, Raster inRaster) {
    int dstOffX = inRaster.getMinX() + x;
    int dstOffY = inRaster.getMinY() + y;
    int width  = inRaster.getWidth();
    int height = inRaster.getHeight();
    if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
        (dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
        throw new ArrayIndexOutOfBoundsException
            ("Coordinate out of bounds!");
    }

    setDataElements(dstOffX, dstOffY, width, height, inRaster);
}
 
源代码10 项目: snap-desktop   文件: MaskFormActions.java
private Rectangle2D handleImageMask(Mask mask, AffineTransform i2m) {
    RenderedImage image = mask.getSourceImage().getImage(0);
    final int minTileX = image.getMinTileX();
    final int minTileY = image.getMinTileY();
    final int numXTiles = image.getNumXTiles();
    final int numYTiles = image.getNumYTiles();
    final int width = image.getWidth();
    final int height = image.getHeight();
    int minX = width;
    int maxX = 0;
    int minY = height;
    int maxY = 0;

    for (int tileX = minTileX; tileX < minTileX + numXTiles; ++tileX) {
        for (int tileY = minTileY; tileY < minTileY + numYTiles; ++tileY) {
            final Raster data = image.getTile(tileX, tileY);
            for (int x = data.getMinX(); x < data.getMinX() + data.getWidth(); x++) {
                for (int y = data.getMinY(); y < data.getMinY() + data.getHeight(); y++) {
                    if (data.getSample(x, y, 0) != 0) {
                        minX = Math.min(x, minX);
                        maxX = Math.max(x, maxX);
                        minY = Math.min(y, minY);
                        maxY = Math.max(y, maxY);
                    }
                }
            }
        }
    }
    Rectangle rect = new Rectangle(minX, minY, maxX - minX + 1, maxY - minY + 1);
    if (rect.isEmpty()) {
        return null;
    } else {
        return i2m.createTransformedShape(rect).getBounds2D();
    }
}
 
源代码11 项目: openjdk-jdk9   文件: IntegerInterleavedRaster.java
/**
 * Stores the Raster data at the specified location.
 * The transferType of the inputRaster must match this raster.
 * An ArrayIndexOutOfBoundsException will be thrown at runtime
 * if the pixel coordinates are out of bounds.
 * @param x          The X coordinate of the pixel location.
 * @param y          The Y coordinate of the pixel location.
 * @param inRaster   Raster of data to place at x,y location.
 */
public void setDataElements(int x, int y, Raster inRaster) {
    int dstOffX = x + inRaster.getMinX();
    int dstOffY = y + inRaster.getMinY();
    int width  = inRaster.getWidth();
    int height = inRaster.getHeight();
    if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
        (dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
        throw new ArrayIndexOutOfBoundsException
            ("Coordinate out of bounds!");
    }

    setDataElements(dstOffX, dstOffY, width, height, inRaster);
}
 
源代码12 项目: TencentKona-8   文件: ByteComponentRaster.java
/**
 * Stores the Raster data at the specified location.
 * An ArrayIndexOutOfBounds exception will be thrown at runtime
 * if the pixel coordinates are out of bounds.
 * @param x          The X coordinate of the pixel location.
 * @param y          The Y coordinate of the pixel location.
 * @param inRaster   Raster of data to place at x,y location.
 */
public void setDataElements(int x, int y, Raster inRaster) {
    int dstOffX = inRaster.getMinX() + x;
    int dstOffY = inRaster.getMinY() + y;
    int width  = inRaster.getWidth();
    int height = inRaster.getHeight();
    if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
        (dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
        throw new ArrayIndexOutOfBoundsException
            ("Coordinate out of bounds!");
    }

    setDataElements(dstOffX, dstOffY, width, height, inRaster);
}
 
源代码13 项目: dragonwell8_jdk   文件: ShortInterleavedRaster.java
/**
 * Stores the Raster data at the specified location.
 * An ArrayIndexOutOfBounds exception will be thrown at runtime
 * if the pixel coordinates are out of bounds.
 * @param x          The X coordinate of the pixel location.
 * @param y          The Y coordinate of the pixel location.
 * @param inRaster   Raster of data to place at x,y location.
 */
public void setDataElements(int x, int y, Raster inRaster) {
    int dstOffX = x + inRaster.getMinX();
    int dstOffY = y + inRaster.getMinY();
    int width  = inRaster.getWidth();
    int height = inRaster.getHeight();
    if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
        (dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
        throw new ArrayIndexOutOfBoundsException
            ("Coordinate out of bounds!");
    }

    setDataElements(dstOffX, dstOffY, width, height, inRaster);
}
 
源代码14 项目: dragonwell8_jdk   文件: ShortBandedRaster.java
/**
 * Stores the Raster data at the specified location.
 * An ArrayIndexOutOfBounds exception will be thrown at runtime
 * if the pixel coordinates are out of bounds.
 * @param x          The X coordinate of the pixel location.
 * @param y          The Y coordinate of the pixel location.
 * @param inRaster   Raster of data to place at x,y location.
 */
public void setDataElements(int x, int y, Raster inRaster) {
    int dstOffX = x + inRaster.getMinX();
    int dstOffY = y + inRaster.getMinY();
    int width  = inRaster.getWidth();
    int height = inRaster.getHeight();
    if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
        (dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
        throw new ArrayIndexOutOfBoundsException
            ("Coordinate out of bounds!");
    }

    setDataElements(dstOffX, dstOffY, width, height, inRaster);
}
 
源代码15 项目: jdk8u_jdk   文件: ByteInterleavedRaster.java
/**
 * Stores the Raster data at the specified location.
 * @param dstX The absolute X coordinate of the destination pixel
 * that will receive a copy of the upper-left pixel of the
 * inRaster
 * @param dstY The absolute Y coordinate of the destination pixel
 * that will receive a copy of the upper-left pixel of the
 * inRaster
 * @param srcX The absolute X coordinate of the upper-left source
 * pixel that will be copied into this Raster
 * @param srcY The absolute Y coordinate of the upper-left source
 * pixel that will be copied into this Raster
 * @param width      The number of pixels to store horizontally
 * @param height     The number of pixels to store vertically
 * @param inRaster   Raster of data to place at x,y location.
 */
private void setDataElements(int dstX, int dstY,
                             int srcX, int srcY,
                             int width, int height,
                             Raster inRaster) {
    // Assume bounds checking has been performed previously
    if (width <= 0 || height <= 0) {
        return;
    }

    // Write inRaster (minX, minY) to (dstX, dstY)

    int srcOffX = inRaster.getMinX();
    int srcOffY = inRaster.getMinY();
    Object tdata = null;

    if (inRaster instanceof ByteInterleavedRaster) {
        ByteInterleavedRaster bct = (ByteInterleavedRaster) inRaster;
        byte[] bdata = bct.getDataStorage();
        // copy whole scanlines
        if (inOrder && bct.inOrder && pixelStride == bct.pixelStride) {
            int toff = bct.getDataOffset(0);
            int tss  = bct.getScanlineStride();
            int tps  = bct.getPixelStride();

            int srcOffset = toff +
                (srcY - srcOffY) * tss +
                (srcX - srcOffX) * tps;
            int dstOffset = dataOffsets[0] +
                (dstY - minY) * scanlineStride +
                (dstX - minX) * pixelStride;

            int nbytes = width*pixelStride;
            for (int tmpY=0; tmpY < height; tmpY++) {
                System.arraycopy(bdata, srcOffset,
                                 data, dstOffset, nbytes);
                srcOffset += tss;
                dstOffset += scanlineStride;
            }
            markDirty();
            return;
        }
    }

    for (int startY=0; startY < height; startY++) {
        // Grab one scanline at a time
        tdata = inRaster.getDataElements(srcOffX, srcOffY+startY,
                                         width, 1, tdata);
        setDataElements(dstX, dstY + startY, width, 1, tdata);
    }
}
 
源代码16 项目: jdk8u_jdk   文件: IntegerInterleavedRaster.java
/**
 * Stores the Raster data at the specified location.
 * @param dstX The absolute X coordinate of the destination pixel
 * that will receive a copy of the upper-left pixel of the
 * inRaster
 * @param dstY The absolute Y coordinate of the destination pixel
 * that will receive a copy of the upper-left pixel of the
 * inRaster
 * @param width      The number of pixels to store horizontally
 * @param height     The number of pixels to store vertically
 * @param inRaster   Raster of data to place at x,y location.
 */
private void setDataElements(int dstX, int dstY,
                             int width, int height,
                             Raster inRaster) {
    // Assume bounds checking has been performed previously
    if (width <= 0 || height <= 0) {
        return;
    }

    // Write inRaster (minX, minY) to (dstX, dstY)

    int srcOffX = inRaster.getMinX();
    int srcOffY = inRaster.getMinY();
    int tdata[] = null;

    if (inRaster instanceof IntegerInterleavedRaster) {
        IntegerInterleavedRaster ict = (IntegerInterleavedRaster) inRaster;

        // Extract the raster parameters
        tdata    = ict.getDataStorage();
        int tss  = ict.getScanlineStride();
        int toff = ict.getDataOffset(0);

        int srcOffset = toff;
        int dstOffset = dataOffsets[0]+(dstY-minY)*scanlineStride+
                                       (dstX-minX);


        // Fastest case.  We can copy scanlines
        // Loop through all of the scanlines and copy the data
        for (int startY=0; startY < height; startY++) {
            System.arraycopy(tdata, srcOffset, data, dstOffset, width);
            srcOffset += tss;
            dstOffset += scanlineStride;
        }
        markDirty();
        return;
    }

    Object odata = null;
    for (int startY=0; startY < height; startY++) {
        // Grab one scanline at a time
        odata = inRaster.getDataElements(srcOffX, srcOffY+startY,
                                         width, 1, odata);
        setDataElements(dstX, dstY+startY, width, 1, odata);
    }
}
 
源代码17 项目: jdk8u-dev-jdk   文件: ByteInterleavedRaster.java
/**
 * Stores the Raster data at the specified location.
 * @param dstX The absolute X coordinate of the destination pixel
 * that will receive a copy of the upper-left pixel of the
 * inRaster
 * @param dstY The absolute Y coordinate of the destination pixel
 * that will receive a copy of the upper-left pixel of the
 * inRaster
 * @param srcX The absolute X coordinate of the upper-left source
 * pixel that will be copied into this Raster
 * @param srcY The absolute Y coordinate of the upper-left source
 * pixel that will be copied into this Raster
 * @param width      The number of pixels to store horizontally
 * @param height     The number of pixels to store vertically
 * @param inRaster   Raster of data to place at x,y location.
 */
private void setDataElements(int dstX, int dstY,
                             int srcX, int srcY,
                             int width, int height,
                             Raster inRaster) {
    // Assume bounds checking has been performed previously
    if (width <= 0 || height <= 0) {
        return;
    }

    // Write inRaster (minX, minY) to (dstX, dstY)

    int srcOffX = inRaster.getMinX();
    int srcOffY = inRaster.getMinY();
    Object tdata = null;

    if (inRaster instanceof ByteInterleavedRaster) {
        ByteInterleavedRaster bct = (ByteInterleavedRaster) inRaster;
        byte[] bdata = bct.getDataStorage();
        // copy whole scanlines
        if (inOrder && bct.inOrder && pixelStride == bct.pixelStride) {
            int toff = bct.getDataOffset(0);
            int tss  = bct.getScanlineStride();
            int tps  = bct.getPixelStride();

            int srcOffset = toff +
                (srcY - srcOffY) * tss +
                (srcX - srcOffX) * tps;
            int dstOffset = dataOffsets[0] +
                (dstY - minY) * scanlineStride +
                (dstX - minX) * pixelStride;

            int nbytes = width*pixelStride;
            for (int tmpY=0; tmpY < height; tmpY++) {
                System.arraycopy(bdata, srcOffset,
                                 data, dstOffset, nbytes);
                srcOffset += tss;
                dstOffset += scanlineStride;
            }
            markDirty();
            return;
        }
    }

    for (int startY=0; startY < height; startY++) {
        // Grab one scanline at a time
        tdata = inRaster.getDataElements(srcOffX, srcOffY+startY,
                                         width, 1, tdata);
        setDataElements(dstX, dstY + startY, width, 1, tdata);
    }
}
 
源代码18 项目: openjdk-jdk9   文件: ByteInterleavedRaster.java
/**
 * Stores the Raster data at the specified location.
 * @param dstX The absolute X coordinate of the destination pixel
 * that will receive a copy of the upper-left pixel of the
 * inRaster
 * @param dstY The absolute Y coordinate of the destination pixel
 * that will receive a copy of the upper-left pixel of the
 * inRaster
 * @param srcX The absolute X coordinate of the upper-left source
 * pixel that will be copied into this Raster
 * @param srcY The absolute Y coordinate of the upper-left source
 * pixel that will be copied into this Raster
 * @param width      The number of pixels to store horizontally
 * @param height     The number of pixels to store vertically
 * @param inRaster   Raster of data to place at x,y location.
 */
private void setDataElements(int dstX, int dstY,
                             int srcX, int srcY,
                             int width, int height,
                             Raster inRaster) {
    // Assume bounds checking has been performed previously
    if (width <= 0 || height <= 0) {
        return;
    }

    // Write inRaster (minX, minY) to (dstX, dstY)

    int srcOffX = inRaster.getMinX();
    int srcOffY = inRaster.getMinY();
    Object tdata = null;

    if (inRaster instanceof ByteInterleavedRaster) {
        ByteInterleavedRaster bct = (ByteInterleavedRaster) inRaster;
        byte[] bdata = bct.getDataStorage();
        // copy whole scanlines
        if (inOrder && bct.inOrder && pixelStride == bct.pixelStride) {
            int toff = bct.getDataOffset(0);
            int tss  = bct.getScanlineStride();
            int tps  = bct.getPixelStride();

            int srcOffset = toff +
                (srcY - srcOffY) * tss +
                (srcX - srcOffX) * tps;
            int dstOffset = dataOffsets[0] +
                (dstY - minY) * scanlineStride +
                (dstX - minX) * pixelStride;

            int nbytes = width*pixelStride;
            for (int tmpY=0; tmpY < height; tmpY++) {
                System.arraycopy(bdata, srcOffset,
                                 data, dstOffset, nbytes);
                srcOffset += tss;
                dstOffset += scanlineStride;
            }
            markDirty();
            return;
        }
    }

    for (int startY=0; startY < height; startY++) {
        // Grab one scanline at a time
        tdata = inRaster.getDataElements(srcOffX, srcOffY+startY,
                                         width, 1, tdata);
        setDataElements(dstX, dstY + startY, width, 1, tdata);
    }
}
 
源代码19 项目: hottub   文件: ByteComponentRaster.java
/**
 * Stores the Raster data at the specified location.
 * @param dstX The absolute X coordinate of the destination pixel
 * that will receive a copy of the upper-left pixel of the
 * inRaster
 * @param dstY The absolute Y coordinate of the destination pixel
 * that will receive a copy of the upper-left pixel of the
 * inRaster
 * @param width      The number of pixels to store horizontally
 * @param height     The number of pixels to store vertically
 * @param inRaster   Raster of data to place at x,y location.
 */
private void setDataElements(int dstX, int dstY,
                             int width, int height,
                             Raster inRaster) {
    // Assume bounds checking has been performed previously
    if (width <= 0 || height <= 0) {
        return;
    }

    int srcOffX = inRaster.getMinX();
    int srcOffY = inRaster.getMinY();
    Object tdata = null;

    if (inRaster instanceof ByteComponentRaster) {
        ByteComponentRaster bct = (ByteComponentRaster) inRaster;
        byte[] bdata = bct.getDataStorage();
        // REMIND: Do something faster!
        if (numDataElements == 1) {
            int toff = bct.getDataOffset(0);
            int tss  = bct.getScanlineStride();

            int srcOffset = toff;
            int dstOffset = dataOffsets[0]+(dstY-minY)*scanlineStride+
                                           (dstX-minX);


            if (pixelStride == bct.getPixelStride()) {
                width *= pixelStride;
                for (int tmpY=0; tmpY < height; tmpY++) {
                    System.arraycopy(bdata, srcOffset,
                                     data, dstOffset, width);
                    srcOffset += tss;
                    dstOffset += scanlineStride;
                }
                markDirty();
                return;
            }
        }
    }

    for (int startY=0; startY < height; startY++) {
        // Grab one scanline at a time
        tdata = inRaster.getDataElements(srcOffX, srcOffY+startY,
                                         width, 1, tdata);
        setDataElements(dstX, dstY+startY, width, 1, tdata);
    }
}
 
源代码20 项目: jdk8u60   文件: IntegerComponentRaster.java
/**
 * Stores the Raster data at the specified location.
 * @param dstX The absolute X coordinate of the destination pixel
 * that will receive a copy of the upper-left pixel of the
 * inRaster
 * @param dstY The absolute Y coordinate of the destination pixel
 * that will receive a copy of the upper-left pixel of the
 * inRaster
 * @param width      The number of pixels to store horizontally
 * @param height     The number of pixels to store vertically
 * @param inRaster   Raster of data to place at x,y location.
 */
private void setDataElements(int dstX, int dstY,
                             int width, int height,
                             Raster inRaster) {
    // Assume bounds checking has been performed previously
    if (width <= 0 || height <= 0) {
        return;
    }

    // Write inRaster (minX, minY) to (dstX, dstY)

    int srcOffX = inRaster.getMinX();
    int srcOffY = inRaster.getMinY();
    int tdata[] = null;

    if (inRaster instanceof IntegerComponentRaster &&
        (pixelStride == 1) && (numDataElements == 1)) {
        IntegerComponentRaster ict = (IntegerComponentRaster) inRaster;
        if (ict.getNumDataElements() != 1) {
            throw new ArrayIndexOutOfBoundsException("Number of bands"+
                                                     " does not match");
        }

        // Extract the raster parameters
        tdata    = ict.getDataStorage();
        int tss  = ict.getScanlineStride();
        int toff = ict.getDataOffset(0);

        int srcOffset = toff;

        int dstOffset = dataOffsets[0]+(dstY-minY)*scanlineStride+
                                       (dstX-minX);


        // Fastest case.  We can copy scanlines
        if (ict.getPixelStride() == pixelStride) {
            width *= pixelStride;

            // Loop through all of the scanlines and copy the data
            for (int startY=0; startY < height; startY++) {
                System.arraycopy(tdata, srcOffset, data, dstOffset, width);
                srcOffset += tss;
                dstOffset += scanlineStride;
            }
            markDirty();
            return;
        }
    }

    Object odata = null;
    for (int startY=0; startY < height; startY++) {
        odata = inRaster.getDataElements(srcOffX, srcOffY+startY,
                                         width, 1, odata);
        setDataElements(dstX, dstY+startY,
                        width, 1, odata);
    }
}