Package com.emitrom.lienzo.client.core.util

Examples of com.emitrom.lienzo.client.core.util.ScratchCanvas


        }
        if (isCanvasSupported())
        {
            try
            {
                ScratchCanvas scratch = new ScratchCanvas(1, 1);

                m_backingStorePixelRatio = scratch.getContext().getBackingStorePixelRatio();
            }
            catch (Exception e)
            {
                m_backingStorePixelRatio = 1;
View Full Code Here


    {
        if (isCanvasSupported())
        {
            try
            {
                ScratchCanvas scratch = new ScratchCanvas(20, 10);

                Context2D context = scratch.getContext();

                context.setStrokeWidth(10);

                context.setLineCap(LineCap.BUTT);
View Full Code Here

                    return;
                }
                // Prepare the Image for the Selection Layer.
                // Get ImageData of the image by drawing it in a temporary canvas...

                ScratchCanvas scratch = new ScratchCanvas(m_destinationWidth, m_destinationHeight);

                Context2D context = scratch.getContext();

                context.drawImage(m_imageJSO, m_x, m_y, m_width, m_height, 0, 0, m_destinationWidth, m_destinationHeight);

                ImageData imageData = context.getImageData(0, 0, m_destinationWidth, m_destinationHeight);

                // Now draw the image again, replacing each color with the color key

                scratch.clear();

                Color rgb = Color.fromColorString(m_picture.getColorKey());

                context.putImageData(new RGBIgnoreAlphaImageDataFilter(rgb.getR(), rgb.getG(), rgb.getB()).filter(imageData, true), 0, 0);

                // Load the resulting image from the temporary canvas into the selection Image

                String dataURL = scratch.toDataURL();

                new ImageLoader(dataURL)
                {
                    @Override
                    public void onLoaded(ImageLoader image)
View Full Code Here

    {
        if (false == m_loaded)
        {
            return null;
        }
        ScratchCanvas scratch = new ScratchCanvas(m_destinationWidth, m_destinationHeight);

        Context2D context = scratch.getContext();

        context.drawImage(m_imageJSO, m_x, m_y, m_width, m_height, 0, 0, m_destinationWidth, m_destinationHeight);

        ImageData imageData = context.getImageData(0, 0, m_destinationWidth, m_destinationHeight);
View Full Code Here

    {
        if (false == m_loaded)
        {
            return null;
        }
        ScratchCanvas scratch = new ScratchCanvas(m_destinationWidth, m_destinationHeight);

        Context2D context = scratch.getContext();

        context.drawImage(m_imageJSO, m_x, m_y, m_width, m_height, 0, 0, m_destinationWidth, m_destinationHeight);

        if (mimeType == null)
        {
            return scratch.toDataURL();
        }
        else return scratch.toDataURL(mimeType);
    }
View Full Code Here

    /**
     * ImageData can't be cloned or deep-copied, it's an internal data structure and has some CRAZY crap in it, this is cheeeeeezy, but hey, it works, and it's portable!!!
     */
    public final ImageData copy()
    {
        ScratchCanvas scratch = new ScratchCanvas(getWidth(), getHeight());

        Context2D context = scratch.getContext();

        context.putImageData(this, 0, 0);

        return context.getImageData(0, 0, getWidth(), getHeight());
    }
View Full Code Here

    public final String toDataURL()
    {
        if (LienzoGlobals.getInstance().isCanvasSupported())
        {
            ScratchCanvas scratch = new ScratchCanvas(m_wide, m_high);

            FastArrayList<Layer> layers = getChildNodes();

            if (null != layers)
            {
                final int size = layers.length();

                for (int i = size - 1; i >= 0; i--)
                {
                    Layer layer = layers.get(i);

                    if ((null != layer) && (layer.isVisible()))
                    {
                        layer.drawWithTransforms(scratch.getContext());
                    }
                }
            }
            return scratch.toDataURL();
        }
        else
        {
            return "data:,";
        }
View Full Code Here

    final String toDataURL(Layer background)
    {
        if (LienzoGlobals.getInstance().isCanvasSupported())
        {
            ScratchCanvas scratch = new ScratchCanvas(m_wide, m_high);

            FastArrayList<Layer> layers = getChildNodes();

            if (null != layers)
            {
                final int size = layers.length();

                if (null != background)
                {
                    background.drawWithTransforms(scratch.getContext());
                }
                for (int i = size - 1; i >= 0; i--)
                {
                    Layer layer = layers.get(i);

                    if ((null != layer) && (layer.isVisible()))
                    {
                        layer.drawWithTransforms(scratch.getContext());
                    }
                }
            }
            return scratch.toDataURL();
        }
        else
        {
            return "data:,";
        }
View Full Code Here

    public final String toDataURL(DataURLType mimetype)
    {
        if (LienzoGlobals.getInstance().isCanvasSupported())
        {
            ScratchCanvas scratch = new ScratchCanvas(m_wide, m_high);

            FastArrayList<Layer> layers = getChildNodes();

            if (null != layers)
            {
                final int size = layers.length();

                for (int i = size - 1; i >= 0; i--)
                {
                    Layer layer = layers.get(i);

                    if ((null != layer) && (layer.isVisible()))
                    {
                        layer.drawWithTransforms(scratch.getContext());
                    }
                }
            }
            return scratch.toDataURL(mimetype);
        }
        else
        {
            return "data:,";
        }
View Full Code Here

    final String toDataURL(DataURLType mimetype, Layer background)
    {
        if (LienzoGlobals.getInstance().isCanvasSupported())
        {
            ScratchCanvas scratch = new ScratchCanvas(m_wide, m_high);

            FastArrayList<Layer> layers = getChildNodes();

            if (null != layers)
            {
                final int size = layers.length();

                if (null != background)
                {
                    background.drawWithTransforms(scratch.getContext());
                }
                for (int i = size - 1; i >= 0; i--)
                {
                    Layer layer = layers.get(i);

                    if ((null != layer) && (layer.isVisible()))
                    {
                        layer.drawWithTransforms(scratch.getContext());
                    }
                }
            }
            return scratch.toDataURL(mimetype);
        }
        else
        {
            return "data:,";
        }
View Full Code Here

TOP

Related Classes of com.emitrom.lienzo.client.core.util.ScratchCanvas

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.