Example usage for com.google.gwt.typedarrays.shared Int32Array set

List of usage examples for com.google.gwt.typedarrays.shared Int32Array set

Introduction

In this page you can find the example usage for com.google.gwt.typedarrays.shared Int32Array set.

Prototype

void set(int[] array, int offset);

Source Link

Document

Set multiple elements in this view from an array, storing starting at the requested offset.

Usage

From source file:com.lizardtech.djvu.GPixmap.java

License:Open Source License

/**
 * Initialize this pixmap to the specified size and fill in the specified color.
 *
 * @param arows number of rows//from w ww.ja  v  a  2 s.  co m
 * @param acolumns number of columns
 * @param filler fill color
 *
 * @return the initialized pixmap
 */
public GPixmap init(int arows, int acolumns, GPixel filler) {
    //    boolean needFill=false;
    if ((arows != nrows) || (acolumns != ncolumns)) {
        data = null;
        nrows = arows;
        ncolumns = acolumns;
    }

    final int npix = rowOffset(rows());

    if (npix > 0) {
        if (data == null) {
            setImageData(imageDataFactory.createImageData(ncolumns, nrows));
            if (filler == null) {
                for (int i = 0; i < npix; i++)
                    data.set(i * ncolors + 3, 0xFF);
            }
        }

        if (filler != null) {
            data.set(redOffset, filler.redByte());
            data.set(greenOffset, filler.greenByte());
            data.set(blueOffset, filler.blueByte());
            data.set(3, 0xFF);
            Int32Array fillBuffer = TypedArrays.createInt32Array(data.buffer());
            int fillValue = fillBuffer.get(0);
            for (int i = 0; i < npix; i++)
                fillBuffer.set(i, fillValue);
        }
    }

    return this;
}