当前位置: 首页>>代码示例>>Java>>正文


Java Raster.getDataElements方法代码示例

本文整理汇总了Java中java.awt.image.Raster.getDataElements方法的典型用法代码示例。如果您正苦于以下问题:Java Raster.getDataElements方法的具体用法?Java Raster.getDataElements怎么用?Java Raster.getDataElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.image.Raster的用法示例。


在下文中一共展示了Raster.getDataElements方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setDataElements

import java.awt.image.Raster; //导入方法依赖的package包/类
/**
     * 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);
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:ByteBandedRaster.java

示例2: setDataElements

import java.awt.image.Raster; //导入方法依赖的package包/类
/**
     * 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);
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:ShortBandedRaster.java

示例3: setDataElements

import java.awt.image.Raster; //导入方法依赖的package包/类
/**
     * 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 ShortComponentRaster) {
//      }

        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);
        }
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:ShortComponentRaster.java

示例4: getPixels

import java.awt.image.Raster; //导入方法依赖的package包/类
/**
 * <p>Returns an array of pixels, stored as integers, from a <code>BufferedImage</code>. The pixels are grabbed from
 * a rectangular area defined by a location and two dimensions. Calling this method on an image of type different
 * from <code>BufferedImage.TYPE_INT_ARGB</code> and <code>BufferedImage.TYPE_INT_RGB</code> will unmanage the
 * image.</p>
 *
 * @param img    the source image
 * @param x      the x location at which to start grabbing pixels
 * @param y      the y location at which to start grabbing pixels
 * @param w      the width of the rectangle of pixels to grab
 * @param h      the height of the rectangle of pixels to grab
 * @param pixels a pre-allocated array of pixels of size w*h; can be null
 * @return <code>pixels</code> if non-null, a new array of integers otherwise
 * @throws IllegalArgumentException is <code>pixels</code> is non-null and of length &lt; w*h
 */
static byte[] getPixels(BufferedImage img,
                               int x, int y, int w, int h, byte[] pixels) {
    if (w == 0 || h == 0) {
        return new byte[0];
    }

    if (pixels == null) {
        pixels = new byte[w * h];
    } else if (pixels.length < w * h) {
        throw new IllegalArgumentException("pixels array must have a length >= w*h");
    }

    int imageType = img.getType();
    if (imageType == BufferedImage.TYPE_BYTE_GRAY) {
        Raster raster = img.getRaster();
        return (byte[]) raster.getDataElements(x, y, w, h, pixels);
    } else {
        throw new IllegalArgumentException("Only type BYTE_GRAY is supported");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:EffectUtils.java

示例5: setDataElements

import java.awt.image.Raster; //导入方法依赖的package包/类
/**
     * 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 ShortInterleavedRaster) {
//      }

        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);
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:ShortInterleavedRaster.java

示例6: compare

import java.awt.image.Raster; //导入方法依赖的package包/类
private static boolean compare(final BufferedImage in,
                               final BufferedImage out)
{
    final int width = in.getWidth();
    int height = in.getHeight();
    if (out.getWidth() != width || out.getHeight() != height) {
        throw new RuntimeException("Dimensions changed!");
    }

    Raster oldras = in.getRaster();
    ColorModel oldcm = in.getColorModel();
    Raster newras = out.getRaster();
    ColorModel newcm = out.getColorModel();

    for (int j = 0; j < height; j++) {
        for (int i = 0; i < width; i++) {
            Object oldpixel = oldras.getDataElements(i, j, null);
            int oldrgb = oldcm.getRGB(oldpixel);
            int oldalpha = oldcm.getAlpha(oldpixel);

            Object newpixel = newras.getDataElements(i, j, null);
            int newrgb = newcm.getRGB(newpixel);
            int newalpha = newcm.getAlpha(newpixel);

            if (newrgb != oldrgb ||
                newalpha != oldalpha) {
                // showDiff(in, out);
                throw new RuntimeException("Pixels differ at " + i +
                                           ", " + j + " new = " + Integer.toHexString(newrgb) + " old = " + Integer.toHexString(oldrgb));
            }
        }
    }
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:BMPWriteParamTest.java

示例7: checkPixel

import java.awt.image.Raster; //导入方法依赖的package包/类
private static void checkPixel(final Raster raster,
                               final int x, final int y,
                               final int expected) {

    final int[] rgb = (int[]) raster.getDataElements(x, y, null);

    if (rgb[0] != expected) {
        throw new IllegalStateException("bad pixel at (" + x + ", " + y
                      + ") = " + rgb[0] + " expected: " + expected);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:CrashNaNTest.java

示例8: checkPixel

import java.awt.image.Raster; //导入方法依赖的package包/类
private static void checkPixel(final Raster raster,
                               final int x, final int y,
                               final int expected) {

    final int[] rgb = (int[]) raster.getDataElements(x, y, null);

    if (rgb[0] != expected) {
        throw new IllegalStateException("bad pixel at (" + x + ", " + y
            + ") = " + rgb[0] + " expected: " + expected);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:CrashPaintTest.java

示例9: runTest

import java.awt.image.Raster; //导入方法依赖的package包/类
public void runTest(Object context, int numReps) {
    Raster ras = ((Context) context).ras;
    Object elemdata = ((Context) context).elemdata;
    do {
        ras.getDataElements(numReps&7, 0, elemdata);
    } while (--numReps > 0);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:PixelTests.java

示例10: compare

import java.awt.image.Raster; //导入方法依赖的package包/类
private boolean compare(final BufferedImage in, final BufferedImage out) {

            final int width = in.getWidth();
            int height = in.getHeight();
            if (out.getWidth() != width || out.getHeight() != height) {
                throw new RuntimeException("Dimensions changed!");
            }

            Raster oldras = in.getRaster();
            ColorModel oldcm = in.getColorModel();
            Raster newras = out.getRaster();
            ColorModel newcm = out.getColorModel();

            for (int j = 0; j < height; j++) {
                for (int i = 0; i < width; i++) {
                    Object oldpixel = oldras.getDataElements(i, j, null);
                    int oldrgb = oldcm.getRGB(oldpixel);
                    int oldalpha = oldcm.getAlpha(oldpixel);

                    Object newpixel = newras.getDataElements(i, j, null);
                    int newrgb = newcm.getRGB(newpixel);
                    int newalpha = newcm.getAlpha(newpixel);

                    if (newrgb != oldrgb ||
                        newalpha != oldalpha) {
                        // showDiff(in, out);
                        throw new RuntimeException("Pixels differ at " + i +
                                                   ", " + j + " new = " + Integer.toHexString(newrgb) + " old = " + Integer.toHexString(oldrgb));
                    }
                }
            }
            return true;
        }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:BMPCompressionTest.java

示例11: setDataElements

import java.awt.image.Raster; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:67,代码来源:ByteInterleavedRaster.java

示例12: setDataElements

import java.awt.image.Raster; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:59,代码来源:ByteComponentRaster.java

示例13: Blit

import java.awt.image.Raster; //导入方法依赖的package包/类
public void Blit(SurfaceData src, SurfaceData dst,
                 Composite comp, Region clip,
                 int srcx, int srcy, int dstx, int dsty, int w, int h)
{
    Raster srcRast = src.getRaster(srcx, srcy, w, h);
    ColorModel srcCM = src.getColorModel();

    Raster dstRast = dst.getRaster(dstx, dsty, w, h);
    IntegerComponentRaster icr = (IntegerComponentRaster) dstRast;
    int[] dstPix = icr.getDataStorage();

    Region roi = CustomComponent.getRegionOfInterest(src, dst, clip,
                                                     srcx, srcy,
                                                     dstx, dsty, w, h);
    SpanIterator si = roi.getSpanIterator();

    Object srcPix = null;

    int dstScan = icr.getScanlineStride();
    // assert(icr.getPixelStride() == 1);
    srcx -= dstx;
    srcy -= dsty;
    int span[] = new int[4];
    while (si.nextSpan(span)) {
        int rowoff = icr.getDataOffset(0) + span[1] * dstScan + span[0];
        for (int y = span[1]; y < span[3]; y++) {
            int off = rowoff;
            for (int x = span[0]; x < span[2]; x++) {
                srcPix = srcRast.getDataElements(x+srcx, y+srcy, srcPix);
                dstPix[off++] = srcCM.getRGB(srcPix);
            }
            rowoff += dstScan;
        }
    }
    // Pixels in the dest were modified directly, we must
    // manually notify the raster that it was modified
    icr.markDirty();
    // REMIND: We need to do something to make sure that dstRast
    // is put back to the destination (as in the native Release
    // function)
    // src.releaseRaster(srcRast);  // NOP?
    // dst.releaseRaster(dstRast);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:44,代码来源:CustomComponent.java

示例14: setDataElements

import java.awt.image.Raster; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:69,代码来源:IntegerComponentRaster.java

示例15: setDataElements

import java.awt.image.Raster; //导入方法依赖的package包/类
/**
 * 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;

            dataBuffer.markBitmapDirty();
            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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:68,代码来源:ByteInterleavedRaster.java


注:本文中的java.awt.image.Raster.getDataElements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。