Esempio n. 1
0
        public virtual void setDataElements(int x, int y, Raster inRaster)
        {
            int dstX = x + inRaster.getMinX();
            int dstY = y + inRaster.getMinY();

            int w = inRaster.getWidth();
            int h = inRaster.getHeight();

            if (dstX < this.minX || dstX + w > this.minX + this.width ||
                dstY < this.minY || dstY + h > this.minY + this.height)
            {
                // awt.63=Coordinates are not in bounds
                throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
            }

            int    srcX = inRaster.getMinX();
            int    srcY = inRaster.getMinY();
            Object line = null;

            for (int i = 0; i < h; i++)
            {
                line = inRaster.getDataElements(srcX, srcY + i, w, 1, line);
                setDataElements(dstX, dstY + i, w, 1, line);
            }
        }
Esempio n. 2
0
        public virtual void setRect(int dx, int dy, Raster srcRaster)
        {
            int w = srcRaster.getWidth();
            int h = srcRaster.getHeight();

            int srcX = srcRaster.getMinX();
            int srcY = srcRaster.getMinY();

            int dstX = srcX + dx;
            int dstY = srcY + dy;

            if (dstX < this.minX)
            {
                int minOffX = this.minX - dstX;
                w -= minOffX;
                dstX = this.minX;
                srcX += minOffX;
            }

            if (dstY < this.minY)
            {
                int minOffY = this.minY - dstY;
                h -= minOffY;
                dstY = this.minY;
                srcY += minOffY;
            }

            if (dstX + w > this.minX + this.width)
            {
                int maxOffX = (dstX + w) - (this.minX + this.width);
                w -= maxOffX;
            }

            if (dstY + h > this.minY + this.height)
            {
                int maxOffY = (dstY + h) - (this.minY + this.height);
                h -= maxOffY;
            }

            if (w <= 0 || h <= 0)
            {
                return;
            }

            switch (sampleModel.getDataType())
            {
                case DataBuffer.TYPE_BYTE:
                case DataBuffer.TYPE_SHORT:
                case DataBuffer.TYPE_USHORT:
                case DataBuffer.TYPE_INT:
                    int[] iPixelsLine = null;
                    for (int i = 0; i < h; i++)
                    {
                        iPixelsLine = srcRaster.getPixels(srcX, srcY + i, w, 1,
                                iPixelsLine);
                        setPixels(dstX, dstY + i, w, 1, iPixelsLine);
                    }
                    break;

                case DataBuffer.TYPE_FLOAT:
                    float[] fPixelsLine = null;
                    for (int i = 0; i < h; i++)
                    {
                        fPixelsLine = srcRaster.getPixels(srcX, srcY + i, w, 1,
                                fPixelsLine);
                        setPixels(dstX, dstY + i, w, 1, fPixelsLine);
                    }
                    break;

                case DataBuffer.TYPE_DOUBLE:
                    double[] dPixelsLine = null;
                    for (int i = 0; i < h; i++)
                    {
                        dPixelsLine = srcRaster.getPixels(srcX, srcY + i, w, 1,
                                dPixelsLine);
                        setPixels(dstX, dstY + i, w, 1, dPixelsLine);
                    }
                    break;
            }
        }
Esempio n. 3
0
        public virtual void setRect(int dx, int dy, Raster srcRaster)
        {
            int w = srcRaster.getWidth();
            int h = srcRaster.getHeight();

            int srcX = srcRaster.getMinX();
            int srcY = srcRaster.getMinY();

            int dstX = srcX + dx;
            int dstY = srcY + dy;

            if (dstX < this.minX)
            {
                int minOffX = this.minX - dstX;
                w    -= minOffX;
                dstX  = this.minX;
                srcX += minOffX;
            }

            if (dstY < this.minY)
            {
                int minOffY = this.minY - dstY;
                h    -= minOffY;
                dstY  = this.minY;
                srcY += minOffY;
            }

            if (dstX + w > this.minX + this.width)
            {
                int maxOffX = (dstX + w) - (this.minX + this.width);
                w -= maxOffX;
            }

            if (dstY + h > this.minY + this.height)
            {
                int maxOffY = (dstY + h) - (this.minY + this.height);
                h -= maxOffY;
            }

            if (w <= 0 || h <= 0)
            {
                return;
            }

            switch (sampleModel.getDataType())
            {
            case DataBuffer.TYPE_BYTE:
            case DataBuffer.TYPE_SHORT:
            case DataBuffer.TYPE_USHORT:
            case DataBuffer.TYPE_INT:
                int[] iPixelsLine = null;
                for (int i = 0; i < h; i++)
                {
                    iPixelsLine = srcRaster.getPixels(srcX, srcY + i, w, 1,
                                                      iPixelsLine);
                    setPixels(dstX, dstY + i, w, 1, iPixelsLine);
                }
                break;

            case DataBuffer.TYPE_FLOAT:
                float[] fPixelsLine = null;
                for (int i = 0; i < h; i++)
                {
                    fPixelsLine = srcRaster.getPixels(srcX, srcY + i, w, 1,
                                                      fPixelsLine);
                    setPixels(dstX, dstY + i, w, 1, fPixelsLine);
                }
                break;

            case DataBuffer.TYPE_DOUBLE:
                double[] dPixelsLine = null;
                for (int i = 0; i < h; i++)
                {
                    dPixelsLine = srcRaster.getPixels(srcX, srcY + i, w, 1,
                                                      dPixelsLine);
                    setPixels(dstX, dstY + i, w, 1, dPixelsLine);
                }
                break;
            }
        }
Esempio n. 4
0
        public virtual void setDataElements(int x, int y, Raster inRaster)
        {
            int dstX = x + inRaster.getMinX();
            int dstY = y + inRaster.getMinY();

            int w = inRaster.getWidth();
            int h = inRaster.getHeight();

            if (dstX < this.minX || dstX + w > this.minX + this.width ||
                    dstY < this.minY || dstY + h > this.minY + this.height)
            {
                // awt.63=Coordinates are not in bounds
                throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
            }

            int srcX = inRaster.getMinX();
            int srcY = inRaster.getMinY();
            Object line = null;

            for (int i = 0; i < h; i++)
            {
                line = inRaster.getDataElements(srcX, srcY + i, w, 1, line);
                setDataElements(dstX, dstY + i, w, 1, line);
            }
        }