Search in sources :

Example 6 with ImageData

use of com.ait.lienzo.client.core.types.ImageData in project lienzo-core by ahome-it.

the class EdgeDetectImageDataFilter 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 ImageData result = source.create();
    filter_(data, result.getData(), 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 7 with ImageData

use of com.ait.lienzo.client.core.types.ImageData in project lienzo-core by ahome-it.

the class LienzoCore method examineNativeLineDashSupported.

private final boolean examineNativeLineDashSupported() {
    if (IS_CANVAS_SUPPORTED) {
        try {
            final ScratchPad scratch = new ScratchPad(20, 10);
            final Context2D context = scratch.getContext();
            context.setStrokeWidth(10);
            context.setLineCap(LineCap.BUTT);
            context.setStrokeColor(ColorName.BLUE);
            context.beginPath();
            context.moveTo(0, 5);
            context.lineTo(20, 5);
            context.stroke();
            context.setStrokeColor(ColorName.RED);
            context.setLineDash(new DashArray(5, 5));
            context.beginPath();
            context.moveTo(0, 5);
            context.lineTo(20, 5);
            context.stroke();
            final ImageData backing = context.getImageData(0, 0, 20, 10);
            if (null != backing) {
                if ((backing.getRedAt(3, 5) == 255) && (backing.getBlueAt(3, 5) == 0) && (backing.getGreenAt(3, 5) == 0)) {
                    if ((backing.getRedAt(8, 5) == 0) && (backing.getBlueAt(8, 5) == 255) && (backing.getGreenAt(8, 5) == 0)) {
                        return true;
                    }
                }
            }
        } catch (final Exception e) {
            // FF 22 dev mode does not like line dashes
            error("Line Dash test failed ", e);
        }
    }
    return false;
}
Also used : Context2D(com.ait.lienzo.client.core.Context2D) ImageData(com.ait.lienzo.client.core.types.ImageData) ScratchPad(com.ait.lienzo.client.core.util.ScratchPad) DashArray(com.ait.lienzo.client.core.types.DashArray) UmbrellaException(com.google.gwt.event.shared.UmbrellaException)

Aggregations

ImageData (com.ait.lienzo.client.core.types.ImageData)7 CanvasPixelArray (com.google.gwt.canvas.dom.client.CanvasPixelArray)4 Context2D (com.ait.lienzo.client.core.Context2D)3 ScratchPad (com.ait.lienzo.client.core.util.ScratchPad)2 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)1 DashArray (com.ait.lienzo.client.core.types.DashArray)1 PathPartEntryJSO (com.ait.lienzo.client.core.types.PathPartEntryJSO)1 PathPartList (com.ait.lienzo.client.core.types.PathPartList)1 Point2D (com.ait.lienzo.client.core.types.Point2D)1 Color (com.ait.lienzo.shared.core.types.Color)1 NFastDoubleArrayJSO (com.ait.tooling.nativetools.client.collection.NFastDoubleArrayJSO)1 NFastStringMap (com.ait.tooling.nativetools.client.collection.NFastStringMap)1 UmbrellaException (com.google.gwt.event.shared.UmbrellaException)1