當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。