Пример #1
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));
        }
Пример #2
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;
        }
        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);
        }
Пример #5
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);
        }
Пример #6
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));
        }
Пример #7
0
        public static WritableRaster createInterleavedRaster(int dataType, int w,
                                                             int h, int scanlineStride, int pixelStride, 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 (dataType != DataBuffer.TYPE_BYTE &&
                dataType != DataBuffer.TYPE_USHORT)
            {
                // 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 (bandOffsets == null)
            {
                // awt.27B=bandOffsets is null
                throw new java.lang.NullPointerException("bandOffsets is null"); //$NON-NLS-1$
            }

            int minOffset = bandOffsets[0];

            for (int i = 1; i < bandOffsets.Length; i++)
            {
                if (bandOffsets[i] < minOffset)
                {
                    minOffset = bandOffsets[i];
                }
            }
            int        size = (h - 1) * scanlineStride + w * pixelStride + minOffset;
            DataBuffer data = null;

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

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

            return(createInterleavedRaster(data, w, h, scanlineStride, pixelStride,
                                           bandOffsets, 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;
        }
Пример #9
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;
        }
Пример #10
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);
        }
Пример #11
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);
        }
Пример #12
0
        public static WritableRaster createInterleavedRaster(int dataType, int w,
            int h, int scanlineStride, int pixelStride, 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 (dataType != DataBuffer.TYPE_BYTE
                && dataType != DataBuffer.TYPE_USHORT) {
            // 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 (bandOffsets == null) {
            // awt.27B=bandOffsets is null
            throw new java.lang.NullPointerException("bandOffsets is null"); //$NON-NLS-1$
            }

            int minOffset = bandOffsets[0];
            for (int i = 1; i < bandOffsets.Length; i++) {
            if (bandOffsets[i] < minOffset) {
                minOffset = bandOffsets[i];
            }
            }
            int size = (h - 1) * scanlineStride + w * pixelStride + minOffset;
            DataBuffer data = null;

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

            return createInterleavedRaster(data, w, h, scanlineStride, pixelStride,
                bandOffsets, location);
        }