Search in sources :

Example 1 with CanvasPixelArray

use of com.google.gwt.canvas.dom.client.CanvasPixelArray in project playn by threerings.

the class HtmlCanvasImage method setRgb.

@Override
public void setRgb(int startX, int startY, int width, int height, int[] rgbArray, int offset, int scanSize) {
    Context2d ctx = canvas.canvas().getContext2d();
    ImageData imageData = ctx.createImageData(width, height);
    CanvasPixelArray pixelData = imageData.getData();
    int i = 0;
    int dst = offset;
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            int argb = rgbArray[dst + x];
            pixelData.set(i++, (argb >> 16) & 255);
            pixelData.set(i++, (argb >> 8) & 255);
            pixelData.set(i++, (argb) & 255);
            pixelData.set(i++, (argb >> 24) & 255);
        }
        dst += scanSize;
    }
    ctx.putImageData(imageData, startX, startY);
}
Also used : CanvasPixelArray(com.google.gwt.canvas.dom.client.CanvasPixelArray) Context2d(com.google.gwt.canvas.dom.client.Context2d) ImageData(com.google.gwt.canvas.dom.client.ImageData)

Example 2 with CanvasPixelArray

use of com.google.gwt.canvas.dom.client.CanvasPixelArray in project lienzo-core by ahome-it.

the class AbstractConvolveImageDataFilter method filter.

@Override
public ImageData filter(ImageData source, final boolean copy) {
    if (null == source) {
        return null;
    }
    if (copy) {
        source = source.copy();
    }
    if (false == isActive()) {
        return source;
    }
    final CanvasPixelArray data = source.getData();
    if (null == data) {
        return source;
    }
    final FilterConvolveMatrix matrix = getMatrix();
    if (matrix.size() < 1) {
        return source;
    }
    final ImageData result = source.create();
    FilterCommonOps.doFilterConvolve(data, result.getData(), matrix, source.getWidth(), source.getHeight());
    return result;
}
Also used : CanvasPixelArray(com.google.gwt.canvas.dom.client.CanvasPixelArray) ImageData(com.ait.lienzo.client.core.types.ImageData)

Example 3 with CanvasPixelArray

use of com.google.gwt.canvas.dom.client.CanvasPixelArray in project lienzo-core by ahome-it.

the class AbstractTableImageDataFilter method filter.

@Override
public ImageData filter(ImageData source, final boolean copy) {
    if (null == source) {
        return null;
    }
    if (copy) {
        source = source.copy();
    }
    if (false == isActive()) {
        return source;
    }
    final CanvasPixelArray data = source.getData();
    if (null == data) {
        return source;
    }
    FilterCommonOps.doFilterTable(data, getTable(), source.getWidth(), source.getHeight());
    return source;
}
Also used : CanvasPixelArray(com.google.gwt.canvas.dom.client.CanvasPixelArray)

Example 4 with CanvasPixelArray

use of com.google.gwt.canvas.dom.client.CanvasPixelArray in project lienzo-core by ahome-it.

the class AverageGrayScaleImageDataFilter method filter.

@Override
public ImageData filter(ImageData source, final boolean copy) {
    if (null == source) {
        return null;
    }
    if (copy) {
        source = source.copy();
    }
    if (false == isActive()) {
        return source;
    }
    final CanvasPixelArray data = source.getData();
    if (null == data) {
        return source;
    }
    filter_(data, FilterCommonOps.getLength(source));
    return source;
}
Also used : CanvasPixelArray(com.google.gwt.canvas.dom.client.CanvasPixelArray)

Example 5 with CanvasPixelArray

use of com.google.gwt.canvas.dom.client.CanvasPixelArray in project lienzo-core by ahome-it.

the class ColorLuminosityImageDataFilter method filter.

@Override
public ImageData filter(ImageData source, final boolean copy) {
    if (null == source) {
        return null;
    }
    if (copy) {
        source = source.copy();
    }
    if (false == isActive()) {
        return source;
    }
    final CanvasPixelArray data = source.getData();
    if (null == data) {
        return source;
    }
    filter_(data, FilterCommonOps.getLength(source), getR(), getG(), getB());
    return source;
}
Also used : CanvasPixelArray(com.google.gwt.canvas.dom.client.CanvasPixelArray)

Aggregations

CanvasPixelArray (com.google.gwt.canvas.dom.client.CanvasPixelArray)20 ImageData (com.ait.lienzo.client.core.types.ImageData)4 Context2d (com.google.gwt.canvas.dom.client.Context2d)2 ImageData (com.google.gwt.canvas.dom.client.ImageData)2