Example usage for java.awt.image WritableRaster setRect

List of usage examples for java.awt.image WritableRaster setRect

Introduction

In this page you can find the example usage for java.awt.image WritableRaster setRect.

Prototype

public void setRect(Raster srcRaster) 

Source Link

Document

Copies pixels from Raster srcRaster to this WritableRaster.

Usage

From source file:lucee.runtime.img.Image.java

private static BufferedImage addAlpha(BufferedImage src, BufferedImage alpha, int x, int y) {
    int w = src.getWidth();
    int h = src.getHeight();
    BufferedImage bi = new BufferedImage(w, h, 2);
    WritableRaster wr = bi.getWritableTile(0, 0);
    WritableRaster wr3 = wr.createWritableChild(0, 0, w, h, 0, 0, new int[] { 0, 1, 2 });
    WritableRaster wr1 = wr.createWritableChild(0, 0, w, h, 0, 0, new int[] { 3 });
    wr3.setRect(src.getData());
    wr1.setRect(alpha.getData());/*from  w w  w.  j a v  a 2s.  co m*/
    bi.releaseWritableTile(0, 0);
    return bi;
}

From source file:pl.edu.icm.visnow.lib.utils.ImageUtilities.java

public static BufferedImage addAlpha(BufferedImage src, BufferedImage alpha) {
    int w = src.getWidth();
    int h = src.getHeight();

    BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);

    WritableRaster wr = bi.getWritableTile(0, 0);
    WritableRaster wr3 = wr.createWritableChild(0, 0, w, h, 0, 0, new int[] { 0, 1, 2 });
    WritableRaster wr1 = wr.createWritableChild(0, 0, w, h, 0, 0, new int[] { 3 });
    wr3.setRect(src.getData());
    wr1.setRect(alpha.getData());//  w  w w  .  j av  a 2s. co m

    bi.releaseWritableTile(0, 0);

    return bi;
}