Java Code Examples for java.awt.image.Raster#getMinY()

The following examples show how to use java.awt.image.Raster#getMinY() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShortBandedRaster.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
     * 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();
        Object tdata = null;

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

        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);
        }
    }
 
Example 2
Source File: ByteInterleavedRaster.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source File: ByteBandedRaster.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
     * 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);
        }
    }
 
Example 4
Source File: HMTestCase.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
protected void checkMatrixEqual( Raster image, double[][] matrix ) {
    assertEquals("different dimension", image.getHeight(), matrix.length);
    assertEquals("different dimension", image.getWidth(), matrix[0].length);

    RandomIter randomIter = RandomIterFactory.create(image, null);
    int minX = image.getMinX();
    int minY = image.getMinY();

    for( int j = minY; j < minY + image.getHeight(); j++ ) {
        for( int i = minX; i < minX + image.getWidth(); i++ ) {
            double expectedResult = matrix[i - minX][j - minY];
            double value = randomIter.getSampleDouble(i, j, 0);
            if (isNovalue(value)) {
                assertTrue("Difference at position: " + i + " " + j, isNovalue(expectedResult));
            } else {
                assertEquals("Difference at position: " + i + " " + j, expectedResult, value);
            }
        }
    }

}
 
Example 5
Source File: ByteComponentRaster.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 6
Source File: ByteInterleavedRaster.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 7
Source File: ByteBandedRaster.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 8
Source File: IntegerInterleavedRaster.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 9
Source File: ShortComponentRaster.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 10
Source File: ByteInterleavedRaster.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 11
Source File: ByteBandedRaster.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 12
Source File: ShortComponentRaster.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 13
Source File: ByteBandedRaster.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 14
Source File: IntegerComponentRaster.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example 15
Source File: ContourComposite.java    From Pixelitor with GNU General Public License v3.0 4 votes vote down vote up
@Override
    public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
        int x = src.getMinX();
        int y = src.getMinY();
        int w = src.getWidth();
        int h = src.getHeight();

        int[] srcPix = null;
        int[] srcPix2 = null;
        int[] dstInPix = null;
        int[] dstOutPix = new int[w * 4];

        for (int i = 0; i < h; i++) {
            srcPix = src.getPixels(x, y, w, 1, srcPix);
            dstInPix = dstIn.getPixels(x, y, w, 1, dstInPix);

            int lastAlpha = 0;
            int k = 0;
            for (int j = 0; j < w; j++) {
                int alpha = srcPix[k + 3];
                int alphaAbove = i != 0 ? srcPix2[k + 3] : alpha;

                if (((i != 0) && (j != 0) && (((alpha ^ lastAlpha) & 0x80) != 0)) || (((alpha ^ alphaAbove) & 0x80) != 0)) {
                    if ((offset + i + j) % 10 > 4) {
                        dstOutPix[k] = 0x00;
                        dstOutPix[k + 1] = 0x00;
                        dstOutPix[k + 2] = 0x00;
                    } else {
                        dstOutPix[k] = 0xff;
                        dstOutPix[k + 1] = 0xff;
                        dstOutPix[k + 2] = 0x7f;
                    }
                    dstOutPix[k + 3] = 0xff;
                } else {
                    dstOutPix[k] = dstInPix[k];
                    dstOutPix[k + 1] = dstInPix[k + 1];
                    dstOutPix[k + 2] = dstInPix[k + 2];
//					if ( dstOut == dstIn )
                    dstOutPix[k] = 0xff;
                    dstOutPix[k + 1] = 0;
                    dstOutPix[k + 2] = 0;
                    dstOutPix[k + 3] = 0;
//					else
//						dstOutPix[k+3] = dstInPix[k+3];
                }

                lastAlpha = alpha;
                k += 4;
            }

            dstOut.setPixels(x, y, w, 1, dstOutPix);

            int[] t = srcPix;
            srcPix = srcPix2;
            srcPix2 = t;
            y++;
        }
    }
 
Example 16
Source File: IntegerComponentRaster.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example 17
Source File: ByteComponentRaster.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example 18
Source File: IntegerInterleavedRaster.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example 19
Source File: ByteInterleavedRaster.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example 20
Source File: ByteComponentRaster.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
    }
}