Exemplo n.º 1
0
        public override DataBuffer createDataBuffer()
        {
            DataBuffer data = null;
            int size = scanlineStride * height;

            switch (dataType)
            {
                case DataBuffer.TYPE_BYTE:
                    data = new DataBufferByte(size, numBanks);
                    break;
                case DataBuffer.TYPE_SHORT:
                case DataBuffer.TYPE_USHORT:
                    data = new DataBufferShort(size, numBanks);
                    break;
                case DataBuffer.TYPE_INT:
                    data = new DataBufferInt(size, numBanks);
                    break;
                case DataBuffer.TYPE_FLOAT:
                    data = new DataBufferFloat(size, numBanks);
                    break;
                case DataBuffer.TYPE_DOUBLE:
                    data = new DataBufferDouble(size, numBanks);
                    break;
            }

            return data;
        }
Exemplo n.º 2
0
        public override DataBuffer createDataBuffer()
        {
            DataBuffer data = null;
            int        size = scanlineStride * height;

            switch (dataType)
            {
            case DataBuffer.TYPE_BYTE:
                data = new DataBufferByte(size, numBanks);
                break;

            case DataBuffer.TYPE_SHORT:
            case DataBuffer.TYPE_USHORT:
                data = new DataBufferShort(size, numBanks);
                break;

            case DataBuffer.TYPE_INT:
                data = new DataBufferInt(size, numBanks);
                break;

            case DataBuffer.TYPE_FLOAT:
                data = new DataBufferFloat(size, numBanks);
                break;

            case DataBuffer.TYPE_DOUBLE:
                data = new DataBufferDouble(size, numBanks);
                break;
            }

            return(data);
        }
Exemplo n.º 3
0
        public static WritableRaster createPackedRaster(int dataType, int w, int h,
                                                        int[] bandMasks, Point location)
        {
            if (dataType != DataBuffer.TYPE_BYTE &&
                dataType != DataBuffer.TYPE_USHORT &&
                dataType != DataBuffer.TYPE_INT)
            {
                // awt.230=dataType is not one of the supported data types
                throw new java.lang.IllegalArgumentException("dataType is not one of the supported data types"); //$NON-NLS-1$
            }

            if (w <= 0 || h <= 0)
            {
                // awt.22E=w or h is less than or equal to zero
                throw new RasterFormatException("w or h is less than or equal to zero"); //$NON-NLS-1$
            }

            if (location == null)
            {
                location = new Point(0, 0);
            }

            if ((long)location.x + w > java.lang.Integer.MAX_VALUE ||
                (long)location.y + h > java.lang.Integer.MAX_VALUE)
            {
                // awt.276=location.x + w or location.y + h results in integer overflow
                throw new RasterFormatException("location.x + w or location.y + h results in integer overflow"); //$NON-NLS-1$
            }

            if (bandMasks == null)
            {
                // awt.27C=bandMasks is null
                throw new java.lang.NullPointerException("bandMasks is null"); //$NON-NLS-1$
            }

            DataBuffer data = null;

            switch (dataType)
            {
            case DataBuffer.TYPE_BYTE:
                data = new DataBufferByte(w * h);
                break;

            case DataBuffer.TYPE_USHORT:
                data = new DataBufferUShort(w * h);
                break;

            case DataBuffer.TYPE_INT:
                data = new DataBufferInt(w * h);
                break;
            }

            return(createPackedRaster(data, w, h, w, bandMasks, location));
        }
Exemplo n.º 4
0
        public override DataBuffer createDataBuffer()
        {
            DataBuffer data = null;

            int maxOffset = bandOffsets[0];

            for (int i = 1; i < bandOffsets.Length; i++)
            {
                if (bandOffsets[i] > maxOffset)
                {
                    maxOffset = bandOffsets[i];
                }
            }
            int size = (height - 1) * scanlineStride +
                       (width - 1) * pixelStride + maxOffset + 1;

            switch (dataType)
            {
            case DataBuffer.TYPE_BYTE:
                data = new DataBufferByte(size, numBanks);
                break;

            case DataBuffer.TYPE_SHORT:
                data = new DataBufferShort(size, numBanks);
                break;

            case DataBuffer.TYPE_USHORT:
                data = new DataBufferUShort(size, numBanks);
                break;

            case DataBuffer.TYPE_INT:
                data = new DataBufferInt(size, numBanks);
                break;

            case DataBuffer.TYPE_FLOAT:
                data = new DataBufferFloat(size, numBanks);
                break;

            case DataBuffer.TYPE_DOUBLE:
                data = new DataBufferDouble(size, numBanks);
                break;
            }

            return(data);
        }
        public override DataBuffer createDataBuffer()
        {
            DataBuffer dataBuffer = null;
            int        size       = scanlineStride * height;

            switch (dataType)
            {
            case DataBuffer.TYPE_BYTE:
                dataBuffer = new DataBufferByte(size + (dataBitOffset + 7) / 8);
                break;

            case DataBuffer.TYPE_USHORT:
                dataBuffer = new DataBufferUShort(size + (dataBitOffset + 15) / 16);
                break;

            case DataBuffer.TYPE_INT:
                dataBuffer = new DataBufferInt(size + (dataBitOffset + 31) / 32);
                break;
            }
            return(dataBuffer);
        }
Exemplo n.º 6
0
        public override DataBuffer createDataBuffer()
        {
            DataBuffer data = null;
            int        size = (this.height - 1) * scanlineStride + width;

            switch (this.dataType)
            {
            case DataBuffer.TYPE_BYTE:
                data = new DataBufferByte(size);
                break;

            case DataBuffer.TYPE_USHORT:
                data = new DataBufferUShort(size);
                break;

            case DataBuffer.TYPE_INT:
                data = new DataBufferInt(size);
                break;
            }
            return(data);
        }
Exemplo n.º 7
0
        public static WritableRaster createBandedRaster(int dataType, int w, int h,
                                                        int scanlineStride, int[] bankIndices, int [] bandOffsets,
                                                        Point location)
        {
            if (w <= 0 || h <= 0)
            {
                // awt.22E=w or h is less than or equal to zero
                throw new RasterFormatException("w or h is less than or equal to zero"); //$NON-NLS-1$
            }

            if (location == null)
            {
                location = new Point(0, 0);
            }

            if ((long)location.x + w > java.lang.Integer.MAX_VALUE ||
                (long)location.y + h > java.lang.Integer.MAX_VALUE)
            {
                // awt.276=location.x + w or location.y + h results in integer overflow
                throw new RasterFormatException("location.x + w or location.y + h results in integer overflow"); //$NON-NLS-1$
            }

            if (bankIndices == null || bandOffsets == null)
            {
                // awt.277=bankIndices or bandOffsets is null
                throw new java.lang.ArrayIndexOutOfBoundsException("bankIndices or bandOffsets is null"); //$NON-NLS-1$
            }

            if (dataType != DataBuffer.TYPE_BYTE &&
                dataType != DataBuffer.TYPE_USHORT &&
                dataType != DataBuffer.TYPE_INT)
            {
                // awt.230=dataType is not one of the supported data types
                throw new java.lang.IllegalArgumentException("dataType is not one of the supported data types"); //$NON-NLS-1$
            }

            int maxOffset = bandOffsets[0];
            int maxBank   = bankIndices[0];

            for (int i = 0; i < bankIndices.Length; i++)
            {
                if (bandOffsets[i] > maxOffset)
                {
                    maxOffset = bandOffsets[i];
                }
                if (bankIndices[i] > maxBank)
                {
                    maxBank = bankIndices[i];
                }
            }

            int numBanks = maxBank + 1;
            int dataSize = scanlineStride * (h - 1) + w + maxOffset;

            DataBuffer data = null;

            switch (dataType)
            {
            case DataBuffer.TYPE_BYTE:
                data = new java.awt.image.DataBufferByte(dataSize, numBanks);
                break;

            case DataBuffer.TYPE_USHORT:
                data = new java.awt.image.DataBufferUShort(dataSize, numBanks);
                break;

            case DataBuffer.TYPE_INT:
                data = new DataBufferInt(dataSize, numBanks);
                break;
            }
            return(createBandedRaster(data, w, h, scanlineStride, bankIndices,
                                      bandOffsets, location));
        }
Exemplo n.º 8
0
        public static WritableRaster createPackedRaster(int dataType, int w, int h,
                                                        int bands, int bitsPerBand, Point location)
        {
            if (w <= 0 || h <= 0)
            {
                // awt.22E=w or h is less than or equal to zero
                throw new RasterFormatException("w or h is less than or equal to zero"); //$NON-NLS-1$
            }

            if (location == null)
            {
                location = new Point(0, 0);
            }

            if ((long)location.x + w > java.lang.Integer.MAX_VALUE ||
                (long)location.y + h > java.lang.Integer.MAX_VALUE)
            {
                // awt.276=location.x + w or location.y + h results in integer overflow
                throw new RasterFormatException("location.x + w or location.y + h results in integer overflow"); //$NON-NLS-1$
            }

            if (bands < 1 || bitsPerBand < 1)
            {
                // awt.27D=bitsPerBand or bands is not greater than zero
                throw new java.lang.IllegalArgumentException("bitsPerBand or bands is not greater than zero"); //$NON-NLS-1$
            }

            if (dataType != DataBuffer.TYPE_BYTE &&
                dataType != DataBuffer.TYPE_USHORT &&
                dataType != DataBuffer.TYPE_INT)
            {
                // awt.230=dataType is not one of the supported data types
                throw new java.lang.IllegalArgumentException("dataType is not one of the supported data types"); //$NON-NLS-1$
            }

            if (bitsPerBand * bands > DataBuffer.getDataTypeSize(dataType))
            {
                // awt.27E=The product of bitsPerBand and bands is greater than the number of bits held by dataType
                throw new java.lang.IllegalArgumentException("The product of bitsPerBand and bands is greater than the number of bits held by dataType"); //$NON-NLS-1$
            }

            if (bands > 1)
            {
                int[] bandMasks = new int[bands];
                int   mask      = (1 << bitsPerBand) - 1;

                for (int i = 0; i < bands; i++)
                {
                    bandMasks[i] = mask << (bitsPerBand * (bands - 1 - i));
                }

                return(createPackedRaster(dataType, w, h, bandMasks, location));
            }
            DataBuffer data = null;
            int        size = ((bitsPerBand * w +
                                DataBuffer.getDataTypeSize(dataType) - 1) /
                               DataBuffer.getDataTypeSize(dataType)) * h;

            switch (dataType)
            {
            case DataBuffer.TYPE_BYTE:
                data = new DataBufferByte(size);
                break;

            case DataBuffer.TYPE_USHORT:
                data = new DataBufferUShort(size);
                break;

            case DataBuffer.TYPE_INT:
                data = new DataBufferInt(size);
                break;
            }
            return(createPackedRaster(data, w, h, bitsPerBand, location));
        }
        public override DataBuffer createDataBuffer()
        {
            DataBuffer data = null;
            int size = (this.height - 1) * scanlineStride + width;

            switch (this.dataType)
            {
                case DataBuffer.TYPE_BYTE:
                    data = new DataBufferByte(size);
                    break;
                case DataBuffer.TYPE_USHORT:
                    data = new DataBufferUShort(size);
                    break;
                case DataBuffer.TYPE_INT:
                    data = new DataBufferInt(size);
                    break;
            }
            return data;
        }
        public override DataBuffer createDataBuffer()
        {
            DataBuffer dataBuffer = null;
            int size = scanlineStride * height;

            switch (dataType)
            {
                case DataBuffer.TYPE_BYTE:
                    dataBuffer = new DataBufferByte(size + (dataBitOffset + 7) / 8);
                    break;
                case DataBuffer.TYPE_USHORT:
                    dataBuffer = new DataBufferUShort(size + (dataBitOffset + 15) / 16);
                    break;
                case DataBuffer.TYPE_INT:
                    dataBuffer = new DataBufferInt(size + (dataBitOffset + 31) / 32);
                    break;
            }
            return dataBuffer;
        }
Exemplo n.º 11
0
        public override DataBuffer createDataBuffer()
        {
            DataBuffer data = null;

            int maxOffset = bandOffsets[0];
            for (int i = 1; i < bandOffsets.Length; i++)
            {
                if (bandOffsets[i] > maxOffset)
                {
                    maxOffset = bandOffsets[i];
                }
            }
            int size = (height - 1) * scanlineStride +
            (width - 1) * pixelStride + maxOffset + 1;

            switch (dataType)
            {
                case DataBuffer.TYPE_BYTE:
                    data = new DataBufferByte(size, numBanks);
                    break;
                case DataBuffer.TYPE_SHORT:
                    data = new DataBufferShort(size, numBanks);
                    break;
                case DataBuffer.TYPE_USHORT:
                    data = new DataBufferUShort(size, numBanks);
                    break;
                case DataBuffer.TYPE_INT:
                    data = new DataBufferInt(size, numBanks);
                    break;
                case DataBuffer.TYPE_FLOAT:
                    data = new DataBufferFloat(size, numBanks);
                    break;
                case DataBuffer.TYPE_DOUBLE:
                    data = new DataBufferDouble(size, numBanks);
                    break;
            }

            return data;
        }
Exemplo n.º 12
0
        public static WritableRaster createPackedRaster(int dataType, int w, int h,
            int[] bandMasks, Point location)
        {
            if (dataType != DataBuffer.TYPE_BYTE
                && dataType != DataBuffer.TYPE_USHORT
                && dataType != DataBuffer.TYPE_INT) {
            // awt.230=dataType is not one of the supported data types
            throw new java.lang.IllegalArgumentException("dataType is not one of the supported data types"); //$NON-NLS-1$
            }

            if (w <= 0 || h <= 0) {
            // awt.22E=w or h is less than or equal to zero
            throw new RasterFormatException("w or h is less than or equal to zero"); //$NON-NLS-1$
            }

            if (location == null) {
            location = new Point(0, 0);
            }

            if ((long) location.x + w > java.lang.Integer.MAX_VALUE
                || (long) location.y + h > java.lang.Integer.MAX_VALUE) {
            // awt.276=location.x + w or location.y + h results in integer overflow
            throw new RasterFormatException("location.x + w or location.y + h results in integer overflow"); //$NON-NLS-1$
            }

            if (bandMasks == null) {
            // awt.27C=bandMasks is null
            throw new java.lang.NullPointerException("bandMasks is null"); //$NON-NLS-1$
            }

            DataBuffer data = null;

            switch (dataType) {
            case DataBuffer.TYPE_BYTE:
            data = new DataBufferByte(w * h);
            break;
            case DataBuffer.TYPE_USHORT:
            data = new DataBufferUShort(w * h);
            break;
            case DataBuffer.TYPE_INT:
            data = new DataBufferInt(w * h);
            break;
            }

            return createPackedRaster(data, w, h, w, bandMasks, location);
        }
Exemplo n.º 13
0
        public static WritableRaster createPackedRaster(int dataType, int w, int h,
            int bands, int bitsPerBand, Point location)
        {
            if (w <= 0 || h <= 0) {
            // awt.22E=w or h is less than or equal to zero
            throw new RasterFormatException("w or h is less than or equal to zero"); //$NON-NLS-1$
            }

            if (location == null) {
            location = new Point(0, 0);
            }

            if ((long) location.x + w > java.lang.Integer.MAX_VALUE
                || (long) location.y + h > java.lang.Integer.MAX_VALUE) {
            // awt.276=location.x + w or location.y + h results in integer overflow
            throw new RasterFormatException("location.x + w or location.y + h results in integer overflow"); //$NON-NLS-1$
            }

            if (bands < 1 || bitsPerBand < 1) {
            // awt.27D=bitsPerBand or bands is not greater than zero
            throw new java.lang.IllegalArgumentException("bitsPerBand or bands is not greater than zero"); //$NON-NLS-1$
            }

            if (dataType != DataBuffer.TYPE_BYTE
                && dataType != DataBuffer.TYPE_USHORT
                && dataType != DataBuffer.TYPE_INT) {
            // awt.230=dataType is not one of the supported data types
            throw new java.lang.IllegalArgumentException("dataType is not one of the supported data types"); //$NON-NLS-1$
            }

            if (bitsPerBand * bands > DataBuffer.getDataTypeSize(dataType)) {
            // awt.27E=The product of bitsPerBand and bands is greater than the number of bits held by dataType
            throw new java.lang.IllegalArgumentException("The product of bitsPerBand and bands is greater than the number of bits held by dataType"); //$NON-NLS-1$
            }

            if (bands > 1) {

            int[] bandMasks = new int[bands];
            int mask = (1 << bitsPerBand) - 1;

            for (int i = 0; i < bands; i++) {
                bandMasks[i] = mask << (bitsPerBand * (bands - 1 - i));
            }

            return createPackedRaster(dataType, w, h, bandMasks, location);
            }
            DataBuffer data = null;
            int size = ((bitsPerBand * w +
                DataBuffer.getDataTypeSize(dataType) - 1) /
                DataBuffer.getDataTypeSize(dataType)) * h;

            switch (dataType) {
            case DataBuffer.TYPE_BYTE:
            data = new DataBufferByte(size);
            break;
            case DataBuffer.TYPE_USHORT:
            data = new DataBufferUShort(size);
            break;
            case DataBuffer.TYPE_INT:
            data = new DataBufferInt(size);
            break;
            }
            return createPackedRaster(data, w, h, bitsPerBand, location);
        }
Exemplo n.º 14
0
        public static WritableRaster createBandedRaster(int dataType, int w, int h,
            int scanlineStride, int[] bankIndices, int []bandOffsets,
            Point location)
        {
            if (w <= 0 || h <= 0) {
            // awt.22E=w or h is less than or equal to zero
            throw new RasterFormatException("w or h is less than or equal to zero"); //$NON-NLS-1$
            }

            if (location == null) {
            location = new Point(0, 0);
            }

            if ((long) location.x + w > java.lang.Integer.MAX_VALUE
                || (long) location.y + h > java.lang.Integer.MAX_VALUE) {
            // awt.276=location.x + w or location.y + h results in integer overflow
            throw new RasterFormatException("location.x + w or location.y + h results in integer overflow"); //$NON-NLS-1$
            }

            if (bankIndices == null || bandOffsets == null) {
            // awt.277=bankIndices or bandOffsets is null
            throw new java.lang.ArrayIndexOutOfBoundsException("bankIndices or bandOffsets is null"); //$NON-NLS-1$
            }

            if (dataType != DataBuffer.TYPE_BYTE
                && dataType != DataBuffer.TYPE_USHORT
                && dataType != DataBuffer.TYPE_INT) {
            // awt.230=dataType is not one of the supported data types
            throw new java.lang.IllegalArgumentException("dataType is not one of the supported data types"); //$NON-NLS-1$
            }

            int maxOffset = bandOffsets[0];
            int maxBank = bankIndices[0];

            for (int i = 0; i < bankIndices.Length; i++) {
            if (bandOffsets[i] > maxOffset) {
                maxOffset = bandOffsets[i];
            }
            if (bankIndices[i] > maxBank) {
                maxBank = bankIndices[i];
            }
            }

            int numBanks = maxBank + 1;
            int dataSize = scanlineStride * (h - 1) + w + maxOffset;

            DataBuffer data = null;

            switch (dataType) {
            case DataBuffer.TYPE_BYTE:
            data = new java.awt.image.DataBufferByte(dataSize, numBanks);
            break;
            case DataBuffer.TYPE_USHORT:
            data = new java.awt.image.DataBufferUShort(dataSize, numBanks);
            break;
            case DataBuffer.TYPE_INT:
            data = new DataBufferInt(dataSize, numBanks);
            break;
            }
            return createBandedRaster(data, w, h, scanlineStride, bankIndices,
                bandOffsets, location);
        }