Search in sources :

Example 6 with CanvasPixelArray

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

the class InvertColorImageDataFilter 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 7 with CanvasPixelArray

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

the class LightnessGrayScaleImageDataFilter 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 8 with CanvasPixelArray

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

the class HtmlImage method getRgb.

@Override
public void getRgb(int startX, int startY, int width, int height, int[] rgbArray, int offset, int scanSize) {
    assert isReady() : "Cannot getRgb() a non-ready image";
    if (canvas == null) {
        canvas = img.getOwnerDocument().createCanvasElement();
        canvas.setHeight(img.getHeight());
        canvas.setWidth(img.getWidth());
        canvas.getContext2d().drawImage(img, 0, 0);
    // img.getOwnerDocument().getBody().appendChild(canvas);
    }
    Context2d ctx = canvas.getContext2d();
    ImageData imageData = ctx.getImageData(startX, startY, 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 r = pixelData.get(i++);
            int g = pixelData.get(i++);
            int b = pixelData.get(i++);
            int a = pixelData.get(i++);
            rgbArray[dst + x] = a << 24 | r << 16 | g << 8 | b;
        }
        dst += scanSize;
    }
}
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 9 with CanvasPixelArray

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

the class AbstractTransformImageDataFilter 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 FilterTransformFunction transform = getTransform();
    if (null == transform) {
        return source;
    }
    final ImageData result = source.create();
    FilterCommonOps.doFilterTransform(data, result.getData(), transform, 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 10 with CanvasPixelArray

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

the class AbstractValueTableImageDataFilter 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(getValue()), source.getWidth(), source.getHeight());
    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