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


Java WritableRaster.setDataElements方法代码示例

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


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

示例1: setPixels

import java.awt.image.WritableRaster; //导入方法依赖的package包/类
/**
 * <p>Writes a rectangular area of pixels in the destination <code>BufferedImage</code>. 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 destination image
 * @param x      the x location at which to start storing pixels
 * @param y      the y location at which to start storing pixels
 * @param w      the width of the rectangle of pixels to store
 * @param h      the height of the rectangle of pixels to store
 * @param pixels an array of pixels, stored as integers
 * @throws IllegalArgumentException is <code>pixels</code> is non-null and of length &lt; w*h
 */
static void setPixels(BufferedImage img,
                             int x, int y, int w, int h, byte[] pixels) {
    if (pixels == null || w == 0 || h == 0) {
        return;
    } 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) {
        WritableRaster raster = img.getRaster();
        raster.setDataElements(x, y, w, h, pixels);
    } else {
        throw new IllegalArgumentException("Only type BYTE_GRAY is supported");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:EffectUtils.java

示例2: createRemoteAWTScreenshot

import java.awt.image.WritableRaster; //导入方法依赖的package包/类
private static RemoteScreenshot createRemoteAWTScreenshot(DebuggerEngine engine, String title, int width, int height, int[] dataArray, AWTComponentInfo componentInfo) {
    final BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    WritableRaster raster = bi.getRaster();
    raster.setDataElements(0, 0, width, height, dataArray);
    if (FAST_FIELDS_SEARCH) {
        ComponentsFieldFinder.findFieldsForComponents(componentInfo);
    }
    return new RemoteScreenshot(engine, title, width, height, bi, componentInfo);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:RemoteAWTScreenshot.java

示例3: runTest

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

示例4: setRaster

import java.awt.image.WritableRaster; //导入方法依赖的package包/类
public void setRaster(int x, int y, int xerr, int yerr,
                      int w, int h, int bWidth, int bHeight,
                      int colincx, int colincxerr,
                      int colincy, int colincyerr,
                      int rowincx, int rowincxerr,
                      int rowincy, int rowincyerr) {
    Object data = null;
    int rowx = x;
    int rowy = y;
    int rowxerr = xerr;
    int rowyerr = yerr;
    WritableRaster srcRas = this.srcRas;
    WritableRaster outRas = this.outRas;
    int rgbs[] = filter ? new int[4] : null;
    for (int j = 0; j < h; j++) {
        x = rowx;
        y = rowy;
        xerr = rowxerr;
        yerr = rowyerr;
        for (int i = 0; i < w; i++) {
            data = srcRas.getDataElements(x, y, data);
            if (filter) {
                int nextx, nexty;
                if ((nextx = x + 1) >= bWidth) {
                    nextx = 0;
                }
                if ((nexty = y + 1) >= bHeight) {
                    nexty = 0;
                }
                rgbs[0] = colorModel.getRGB(data);
                data = srcRas.getDataElements(nextx, y, data);
                rgbs[1] = colorModel.getRGB(data);
                data = srcRas.getDataElements(x, nexty, data);
                rgbs[2] = colorModel.getRGB(data);
                data = srcRas.getDataElements(nextx, nexty, data);
                rgbs[3] = colorModel.getRGB(data);
                int rgb =
                    TexturePaintContext.blend(rgbs, xerr, yerr);
                data = colorModel.getDataElements(rgb, data);
            }
            outRas.setDataElements(i, j, data);
            if ((xerr += colincxerr) < 0) {
                xerr &= Integer.MAX_VALUE;
                x++;
            }
            if ((x += colincx) >= bWidth) {
                x -= bWidth;
            }
            if ((yerr += colincyerr) < 0) {
                yerr &= Integer.MAX_VALUE;
                y++;
            }
            if ((y += colincy) >= bHeight) {
                y -= bHeight;
            }
        }
        if ((rowxerr += rowincxerr) < 0) {
            rowxerr &= Integer.MAX_VALUE;
            rowx++;
        }
        if ((rowx += rowincx) >= bWidth) {
            rowx -= bWidth;
        }
        if ((rowyerr += rowincyerr) < 0) {
            rowyerr &= Integer.MAX_VALUE;
            rowy++;
        }
        if ((rowy += rowincy) >= bHeight) {
            rowy -= bHeight;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:73,代码来源:TexturePaintContext.java

示例5: Blit

import java.awt.image.WritableRaster; //导入方法依赖的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);
    IntegerComponentRaster icr = (IntegerComponentRaster) srcRast;
    int[] srcPix = icr.getDataStorage();

    WritableRaster dstRast =
        (WritableRaster) dst.getRaster(dstx, dsty, w, h);
    ColorModel dstCM = dst.getColorModel();

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

    Object dstPix = null;

    int srcScan = icr.getScanlineStride();
    // assert(icr.getPixelStride() == 1);
    srcx -= dstx;
    srcy -= dsty;
    int span[] = new int[4];
    while (si.nextSpan(span)) {
        int rowoff = (icr.getDataOffset(0) +
                      (srcy + span[1]) * srcScan +
                      (srcx + span[0]));
        for (int y = span[1]; y < span[3]; y++) {
            int off = rowoff;
            for (int x = span[0]; x < span[2]; x++) {
                dstPix = dstCM.getDataElements(srcPix[off++], dstPix);
                dstRast.setDataElements(x, y, dstPix);
            }
            rowoff += srcScan;
        }
    }
    // 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:SunburstApps,项目名称:OpenJSharp,代码行数:44,代码来源:CustomComponent.java


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