Package com.google.gwt.canvas.dom.client

Examples of com.google.gwt.canvas.dom.client.CanvasPixelArray


        if (copy)
        {
            source = source.copy();
        }
        final CanvasPixelArray data = source.getData();

        if (null == data)
        {
            return source;
        }
        for (int i = 0; i < length; i += PIXEL_SZ)
        {
            int v = (int) (((0.21 * data.get(i + R_OFFSET)) + (0.72 * data.get(i + G_OFFSET)) + (0.07 * data.get(i + B_OFFSET))) + 0.5);

            data.set(i + R_OFFSET, v);

            data.set(i + G_OFFSET, v);

            data.set(i + B_OFFSET, v);
        }
        return source;
    }
View Full Code Here


        if (copy)
        {
            source = source.copy();
        }
        final CanvasPixelArray data = source.getData();

        if (null == data)
        {
            return source;
        }
        for (int i = 0; i < length; i += PIXEL_SZ)
        {
            int r = (int) Math.max(Math.min((data.get(i + R_OFFSET) + (m_r_brightness * 255) + 0.5), 255), 0);

            int g = (int) Math.max(Math.min((data.get(i + G_OFFSET) + (m_g_brightness * 255) + 0.5), 255), 0);

            int b = (int) Math.max(Math.min((data.get(i + B_OFFSET) + (m_b_brightness * 255) + 0.5), 255), 0);

            data.set(i + R_OFFSET, r);

            data.set(i + G_OFFSET, g);

            data.set(i + B_OFFSET, b);
        }
        return source;
    }
View Full Code Here

        {
            return null;
        }
        ImageData output = source.copy();

        final CanvasPixelArray srcd = source.getData();

        if (null == srcd)
        {
            return source;
        }
        final CanvasPixelArray dstd = output.getData();

        if (null == dstd)
        {
            return source;
        }
        int side = (int) (Math.sqrt(m_weights.length) + 0.5);

        int half = (int) (Math.floor(side / 2));

        int sw = source.getWidth();

        int sh = source.getHeight();

        int w = sw;

        int h = sh;

        for (int y = 0; y < h; y++)
        {
            for (int x = 0; x < w; x++)
            {
                int sy = y;

                int sx = x;

                int dsto = (y * w + x) * 4;

                int r = 0, g = 0, b = 0;

                for (int cy = 0; cy < side; cy++)
                {
                    for (int cx = 0; cx < side; cx++)
                    {
                        int scy = sy + cy - half;

                        int scx = sx + cx - half;

                        if (scy >= 0 && scy < sh && scx >= 0 && scx < sw)
                        {
                            int srco = (scy * sw + scx) * 4;

                            double wt = m_weights[cy * side + cx];

                            r += srcd.get(srco + R_OFFSET) * wt;

                            g += srcd.get(srco + G_OFFSET) * wt;

                            b += srcd.get(srco + B_OFFSET) * wt;
                        }
                    }
                }
                dstd.set(dsto + R_OFFSET, r);

                dstd.set(dsto + G_OFFSET, g);

                dstd.set(dsto + B_OFFSET, b);
            }
        }
        return output;
    }
View Full Code Here

        if (copy)
        {
            source = source.copy();
        }
        final CanvasPixelArray data = source.getData();

        if (null == data)
        {
            return source;
        }
        for (int i = 0; i < length; i += PIXEL_SZ)
        {
            int r = (int) Math.max(Math.min((data.get(i + R_OFFSET) + (m_brightness * 255) + 0.5), 255), 0);

            int g = (int) Math.max(Math.min((data.get(i + G_OFFSET) + (m_brightness * 255) + 0.5), 255), 0);

            int b = (int) Math.max(Math.min((data.get(i + B_OFFSET) + (m_brightness * 255) + 0.5), 255), 0);

            data.set(i + R_OFFSET, r);

            data.set(i + G_OFFSET, g);

            data.set(i + B_OFFSET, b);
        }
        return source;
    }
View Full Code Here

        if (copy)
        {
            source = source.copy();
        }
        final CanvasPixelArray data = source.getData();

        if (null == data)
        {
            return source;
        }
        for (int i = 0; i < length; i += PIXEL_SZ)
        {
            double m = (((0.21 * data.get(i + R_OFFSET)) + (0.72 * data.get(i + G_OFFSET)) + (0.07 * data.get(i + B_OFFSET))) / 255.0);

            data.set(i + R_OFFSET, (int) ((getR() * m) + 0.5));

            data.set(i + G_OFFSET, (int) ((getG() * m) + 0.5));

            data.set(i + B_OFFSET, (int) ((getB() * m) + 0.5));
        }
        return source;
    }
View Full Code Here

        if (copy)
        {
            source = source.copy();
        }
        final CanvasPixelArray data = source.getData();

        if (null == data)
        {
            return source;
        }
        if (isNative())
        {
            filter0(data, length, getR(), getG(), getB());
        }
        else
        {
            for (int i = 0; i < length; i += PIXEL_SZ)
            {
                data.set(i + R_OFFSET, getR());

                data.set(i + G_OFFSET, getG());

                data.set(i + B_OFFSET, getB());
            }
        }
        return source;
    }
View Full Code Here

        if (copy)
        {
            source = source.copy();
        }
        final CanvasPixelArray data = source.getData();

        if (null == data)
        {
            return source;
        }
        if (isNative())
        {
            filter0(data, length, getR(), getG(), getB());
        }
        else
        {
            for (int i = 0; i < length; i += PIXEL_SZ)
            {
                if (data.get(i + A_OFFSET) > 0)
                {
                    data.set(i + R_OFFSET, getR());

                    data.set(i + G_OFFSET, getG());

                    data.set(i + B_OFFSET, getB());

                    data.set(i + A_OFFSET, 255);
                }
            }
        }
        return source;
    }
View Full Code Here

        if (copy)
        {
            source = source.copy();
        }
        final CanvasPixelArray data = source.getData();

        if (null == data)
        {
            return source;
        }
        for (int i = 0; i < length; i += PIXEL_SZ)
        {
            int v = (int) ((((double) (data.get(i + R_OFFSET) + data.get(i + G_OFFSET) + data.get(i + B_OFFSET))) / 3.0) + 0.5);

            data.set(i + R_OFFSET, v);

            data.set(i + G_OFFSET, v);

            data.set(i + B_OFFSET, v);
        }
        return source;
    }
View Full Code Here

        if (copy)
        {
            source = source.copy();
        }
        final CanvasPixelArray data = source.getData();

        if (null == data)
        {
            return source;
        }
        for (int i = 0; i < length; i += PIXEL_SZ)
        {
            int r = data.get(i + R_OFFSET);

            int g = data.get(i + G_OFFSET);

            int b = data.get(i + B_OFFSET);

            int v = (int) ((((Math.max(Math.max(r, g), b) + Math.min(Math.min(r, g), b))) / 2.0) + 0.5);

            data.set(i + R_OFFSET, v);

            data.set(i + G_OFFSET, v);

            data.set(i + B_OFFSET, v);
        }
        return source;
    }
View Full Code Here

    Context2d context = canvas.getContext2d();
    context.drawImage(imageElement, 0, 0);
    ImageData imageData = context.getImageData(0, 0, width,
        height);

    CanvasPixelArray canvasPixelArray = imageData.getData();

    for (int i = 0; i < canvasPixelArray.getLength(); i += 4) {
      canvasPixelArray.set(i, red);
      canvasPixelArray.set(i + 1, green);
      canvasPixelArray.set(i + 2, blue);
      canvasPixelArray.set(i + 3,
      canvasPixelArray.get(i + 3));
    }
    context.putImageData(imageData, 0, 0);


    return new ConvertedImageResource(
View Full Code Here

TOP

Related Classes of com.google.gwt.canvas.dom.client.CanvasPixelArray

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.