示例#1
0
        public static WritableRaster createInterleavedRaster(DataBuffer dataBuffer,
                                                             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 (dataBuffer == null)
            {
                // awt.278=dataBuffer is null
                throw new java.lang.NullPointerException("dataBuffer is null"); //$NON-NLS-1$
            }

            int dataType = dataBuffer.getDataType();

            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 (dataBuffer.getNumBanks() > 1)
            {
                // awt.27A=dataBuffer has more than one bank
                throw new RasterFormatException("dataBuffer has more than one bank"); //$NON-NLS-1$
            }

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

            PixelInterleavedSampleModel sampleModel =
                new PixelInterleavedSampleModel(dataType, w, h,
                                                pixelStride, scanlineStride, bandOffsets);

            return(new OrdinaryWritableRaster(sampleModel, dataBuffer, location));
        }
示例#2
0
        public static WritableRaster createInterleavedRaster(DataBuffer dataBuffer,
            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 (dataBuffer == null) {
            // awt.278=dataBuffer is null
            throw new java.lang.NullPointerException("dataBuffer is null"); //$NON-NLS-1$
            }

            int dataType = dataBuffer.getDataType();
            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 (dataBuffer.getNumBanks() > 1) {
            // awt.27A=dataBuffer has more than one bank
            throw new RasterFormatException("dataBuffer has more than one bank"); //$NON-NLS-1$
            }

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

            PixelInterleavedSampleModel sampleModel =
            new PixelInterleavedSampleModel(dataType, w, h,
                    pixelStride, scanlineStride, bandOffsets);

            return new OrdinaryWritableRaster(sampleModel, dataBuffer, location);
        }