Example #1
0
        protected Raster(SampleModel sampleModel, DataBuffer dataBuffer,
            Rectangle aRegion, Point sampleModelTranslate, Raster parent)
        {
            if (sampleModel == null || dataBuffer == null || aRegion == null
                || sampleModelTranslate == null) {
            // awt.281=sampleModel, dataBuffer, aRegion or sampleModelTranslate is null
            throw new java.lang.NullPointerException("sampleModel, dataBuffer, aRegion or sampleModelTranslate is null"); //$NON-NLS-1$
            }

            if (aRegion.width <= 0 || aRegion.height <= 0) {
            // awt.282=aRegion has width or height less than or equal to zero
            throw new RasterFormatException("aRegion has width or height less than or equal to zero"); //$NON-NLS-1$
            }

            if ((long) aRegion.x + (long) aRegion.width > java.lang.Integer.MAX_VALUE) {
            // awt.283=Overflow X coordinate of Raster
            throw new RasterFormatException("Overflow X coordinate of Raster"); //$NON-NLS-1$
            }

            if ((long) aRegion.y + (long) aRegion.height > java.lang.Integer.MAX_VALUE) {
            // awt.284=Overflow Y coordinate of Raster
            throw new RasterFormatException("Overflow Y coordinate of Raster"); //$NON-NLS-1$
            }

            validateDataBuffer(dataBuffer, aRegion.width, aRegion.height,
                sampleModel);

            this.sampleModel = sampleModel;
            this.dataBuffer = dataBuffer;
            this.minX = aRegion.x;
            this.minY = aRegion.y;
            this.width = aRegion.width;
            this.height = aRegion.height;
            this.sampleModelTranslateX = sampleModelTranslate.x;
            this.sampleModelTranslateY = sampleModelTranslate.y;
            this.parent = parent;
            this.numBands = sampleModel.getNumBands();
            this.numDataElements = sampleModel.getNumDataElements();
        }
Example #2
0
        public override void setPixels(int x, int y, int w, int h, int[] iArray,
                DataBuffer data)
        {
            int idx = 0;

            for (int i = y; i < y + h; i++)
            {
                for (int j = x; j < x + w; j++)
                {
                    for (int n = 0; n < numBands; n++)
                    {
                        setSample(j, i, n, iArray[idx++], data);
                    }
                }
            }
        }
Example #3
0
        public override void setDataElements(int x, int y, Object obj, DataBuffer data)
        {
            switch (dataType)
            {
                case DataBuffer.TYPE_BYTE:
                    byte[] bdata = (byte[])obj;
                    for (int i = 0; i < numBands; i++)
                    {
                        setSample(x, y, i, bdata[i] & 0xff, data);
                    }
                    break;

                case DataBuffer.TYPE_SHORT:
                case DataBuffer.TYPE_USHORT:
                    short[] sdata = (short[])obj;
                    for (int i = 0; i < numBands; i++)
                    {
                        setSample(x, y, i, sdata[i] & 0xffff, data);
                    }
                    break;

                case DataBuffer.TYPE_INT:
                    int[] idata = (int[])obj;
                    for (int i = 0; i < numBands; i++)
                    {
                        setSample(x, y, i, idata[i], data);
                    }
                    break;

                case DataBuffer.TYPE_FLOAT:
                    float[] fdata = (float[])obj;
                    for (int i = 0; i < numBands; i++)
                    {
                        setSample(x, y, i, fdata[i], data);
                    }
                    break;

                case DataBuffer.TYPE_DOUBLE:
                    double[] ddata = (double[])obj;
                    for (int i = 0; i < numBands; i++)
                    {
                        setSample(x, y, i, ddata[i], data);
                    }
                    break;
            }
        }
Example #4
0
        public override int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
        {
            int[] pixel;
            if (iArray == null)
            {
                pixel = new int[numBands];
            }
            else
            {
                pixel = iArray;
            }

            for (int i = 0; i < numBands; i++)
            {
                pixel[i] = getSample(x, y, i, data);
            }

            return pixel;
        }
 public override void setPixel(int x, int y, int[] iArray, DataBuffer data)
 {
     if (x < 0 || y < 0 || x >= this.width || y >= this.height)
     {
         // awt.63=Coordinates are not in bounds
         throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
     }
     for (int i = 0; i < this.numBands; i++)
     {
         setSample(x, y, i, iArray[i], data);
     }
 }
 public override int getSample(int x, int y, int b, DataBuffer data)
 {
     if (x < 0 || y < 0 || x >= this.width || y >= this.height)
     {
         // awt.63=Coordinates are not in bounds
         throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
     }
     int sample = data.getElem(y * scanlineStride + x);
     return java.dotnet.lang.Operator.shiftRightUnsignet((sample & this.bitMasks[b]), this.bitOffsets[b]);
 }
        public override Object getDataElements(int x, int y, Object obj, DataBuffer data)
        {
            if (x < 0 || y < 0 || x >= this.width || y >= this.height)
            {
                // awt.63=Coordinates are not in bounds
                throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
            }
            switch (getTransferType())
            {
                case DataBuffer.TYPE_BYTE:
                    byte[] bdata;
                    if (obj == null)
                    {
                        bdata = new byte[1];
                    }
                    else
                    {
                        bdata = (byte[])obj;
                    }

                    bdata[0] = (byte)data.getElem(y * scanlineStride + x);
                    obj = bdata;
                    break;
                case DataBuffer.TYPE_USHORT:
                    short[] sdata;
                    if (obj == null)
                    {
                        sdata = new short[1];
                    }
                    else
                    {
                        sdata = (short[])obj;
                    }

                    sdata[0] = (short)data.getElem(y * scanlineStride + x);
                    obj = sdata;
                    break;
                case DataBuffer.TYPE_INT:
                    int[] idata;
                    if (obj == null)
                    {
                        idata = new int[1];
                    }
                    else
                    {
                        idata = (int[])obj;
                    }

                    idata[0] = data.getElem(y * scanlineStride + x);
                    obj = idata;
                    break;
            }
            return obj;
        }
        public override void setSample(int x, int y, int b, int s, DataBuffer data)
        {
            if (b != 0)
            {
                // awt.63=Coordinates are not in bounds
                throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
            }

            setSample(x, y, null, data, 3, s);
        }
        public override int[] getPixels(int x, int y, int w, int h, int[] iArray,
                DataBuffer data)
        {
            if (x < 0 || y < 0 || x > this.width || x + w > this.width
                    || y > this.height || y + h > this.height)
            {
                // awt.63=Coordinates are not in bounds
                throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
            }
            int[] pixels = null;
            int idx = 0;

            if (iArray == null)
            {
                pixels = new int[w * h * numBands];
            }
            else
            {
                pixels = iArray;
            }

            for (int i = y; i < y + h; i++)
            {
                for (int j = x; j < x + w; j++)
                {
                    for (int n = 0; n < numBands; n++)
                    {
                        pixels[idx++] = getSample(j, i, n, data);
                    }
                }
            }

            return pixels;
        }
Example #10
0
        public override Object getDataElements(int x, int y, Object obj, DataBuffer data)
        {
            if (x < 0 || y < 0 || x >= this.width || y >= this.height) {
            // awt.63=Coordinates are not in bounds
            throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
            }
            switch (dataType) {
            case DataBuffer.TYPE_BYTE:
            byte[] bdata;
            if (obj == null) {
                bdata = new byte[numBands];
            } else {
                bdata = (byte[]) obj;
            }

            for (int i = 0; i < numBands; i++) {
                bdata[i] = (byte) getSample(x, y, i, data);
            }

            obj = bdata;
            break;

            case DataBuffer.TYPE_SHORT:
            case DataBuffer.TYPE_USHORT:
            short[] sdata;
            if (obj == null) {
                sdata = new short[numBands];
            } else {
                sdata = (short[]) obj;
            }

            for (int i = 0; i < numBands; i++) {
                sdata[i] = (short) getSample(x, y, i, data);
            }

            obj = sdata;
            break;

            case DataBuffer.TYPE_INT:
            int[] idata;
            if (obj == null) {
                idata = new int[numBands];
            } else {
                idata = (int[]) obj;
            }

            for (int i = 0; i < numBands; i++) {
                idata[i] = getSample(x, y, i, data);
            }

            obj = idata;
            break;

            case DataBuffer.TYPE_FLOAT:
            float[] fdata;
            if (obj == null) {
                fdata = new float[numBands];
            } else {
                fdata = (float[]) obj;
            }

            for (int i = 0; i < numBands; i++) {
                fdata[i] = getSampleFloat(x, y, i, data);
            }

            obj = fdata;
            break;

            case DataBuffer.TYPE_DOUBLE:
            double[] ddata;
            if (obj == null) {
                ddata = new double[numBands];
            } else {
                ddata = (double[]) obj;
            }

            for (int i = 0; i < numBands; i++) {
                ddata[i] = getSampleDouble(x, y, i, data);
            }

            obj = ddata;
            break;
            }

            return obj;
        }
Example #11
0
        public static WritableRaster createBandedRaster(DataBuffer dataBuffer,
            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 (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
                && 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$
            }

            BandedSampleModel sampleModel = new BandedSampleModel(dataType, w, h,
                scanlineStride, bankIndices, bandOffsets);

            return new OrdinaryWritableRaster(sampleModel, dataBuffer, location);
        }
Example #12
0
        private static void validateDataBuffer(DataBuffer dataBuffer, int w,
            int h, SampleModel sampleModel)
        {
            int size = 0;

            if (sampleModel is ComponentSampleModel) {
            ComponentSampleModel csm = (ComponentSampleModel) sampleModel;
            int [] offsets = csm.getBandOffsets();
            int maxOffset = offsets[0];
            for (int i = 1; i < offsets.Length; i++) {
                if (offsets[i] > maxOffset) {
                    maxOffset = offsets[i];
                }
            }
            int scanlineStride = csm.getScanlineStride();
            int pixelStride = csm.getPixelStride();

            size = (h - 1) * scanlineStride +
            (w - 1) * pixelStride + maxOffset + 1;

            } else if (sampleModel is MultiPixelPackedSampleModel) {
            MultiPixelPackedSampleModel mppsm =
                (MultiPixelPackedSampleModel) sampleModel;

            int scanlineStride = mppsm.getScanlineStride();
            int dataBitOffset = mppsm.getDataBitOffset();
            int dataType = dataBuffer.getDataType();

            size = scanlineStride * h;

            switch (dataType) {
            case DataBuffer.TYPE_BYTE:
                size += (dataBitOffset + 7) / 8;
                break;
            case DataBuffer.TYPE_USHORT:
                size += (dataBitOffset + 15) / 16;
                break;
            case DataBuffer.TYPE_INT:
                size += (dataBitOffset + 31) / 32;
                break;
            }
            } else if (sampleModel is SinglePixelPackedSampleModel) {
            SinglePixelPackedSampleModel sppsm =
                (SinglePixelPackedSampleModel) sampleModel;

            int scanlineStride = sppsm.getScanlineStride();
            size = (h - 1) * scanlineStride + w;
            }
            if (dataBuffer.getSize() < size) {
            // awt.298=dataBuffer is too small
            throw new RasterFormatException("dataBuffer is too small"); //$NON-NLS-1$
            }
        }
 public override void setDataElements(int x, int y, Object obj, DataBuffer data)
 {
     setSample(x, y, obj, data, 1, 0);
 }
 public override void setPixel(int x, int y, int[] iArray, DataBuffer data)
 {
     setSample(x, y, iArray, data, 2, 0);
 }
Example #15
0
        public override void setSamples(int x, int y, int w, int h, int b, int[] iArray,
                DataBuffer data)
        {
            int idx = 0;

            for (int i = y; i < y + h; i++)
            {
                for (int j = x; j < x + w; j++)
                {
                    setSample(j, i, b, iArray[idx++], data);
                }
            }
        }
Example #16
0
        public override float getSampleFloat(int x, int y, int b, DataBuffer data)
        {
            if (x < 0 || y < 0 || x >= this.width || y >= this.height)
            {
                // awt.63=Coordinates are not in bounds
                throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
            }

            return data.getElemFloat(bankIndices[b], y * scanlineStride +
                    x * pixelStride + bandOffsets[b]);
        }
Example #17
0
 protected WritableRaster(SampleModel sampleModel, DataBuffer dataBuffer,
                          Point origin) :
     this(sampleModel, dataBuffer, new Rectangle(origin.x, origin.y,
                                                 sampleModel.width, sampleModel.height), origin, null)
 {
 }
Example #18
0
        public override int[] getSamples(int x, int y, int w, int h, int b, int[] iArray,
                DataBuffer data)
        {
            if (x < 0 || y < 0 || x + w > this.width || y + h > this.height)
            {
                // awt.63=Coordinates are not in bounds
                throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
            }
            int[] samples;
            int idx = 0;

            if (iArray == null)
            {
                samples = new int[w * h];
            }
            else
            {
                samples = iArray;
            }

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

            for (int i = y; i < y + h; i++)
            {
                for (int j = x; j < x + w; j++)
                {
                    samples[idx++] = getSample(j, i, b, data);
                }
            }

            return samples;
        }
        /**
         * This method is used by other methods of this class. The behaviour of
         * this method depends on the method which has been invoke this one. The
         * argument methodId is used to choose valid behaviour in a particular case.
         * If methodId is equal to 1 it means that this method has been invoked by
         * the setDataElements() method, 2 - means setPixel(), and setSample() in
         * any other cases.
         */
        private void setSample(int x, int y, Object obj,
                 DataBuffer data, int methodId, int s)
        {
            if ((x < 0) || (y < 0) || (x >= this.width) || (y >= this.height))
            {
                // awt.63=Coordinates are not in bounds
                throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
            }

            int bitnum = dataBitOffset + x * pixelBitStride;
            int idx = y * scanlineStride + bitnum / dataElementSize;
            int shift = dataElementSize - (bitnum & (dataElementSize - 1))
                    - pixelBitStride;
            int mask = ~(bitMask << shift);
            int elem = data.getElem(idx);

            switch (methodId)
            {
                case 1:
                    {                        // Invoked from setDataElements()
                        switch (getTransferType())
                        {
                            case DataBuffer.TYPE_BYTE:
                                s = ((byte[])obj)[0] & 0xff;
                                break;
                            case DataBuffer.TYPE_USHORT:
                                s = ((short[])obj)[0] & 0xffff;
                                break;
                            case DataBuffer.TYPE_INT:
                                s = ((int[])obj)[0];
                                break;
                        }
                        break;
                    }
                case 2:
                    {                        // Invoked from setPixel()
                        s = ((int[])obj)[0];
                        break;
                    }
            }

            elem &= mask;
            elem |= (s & bitMask) << shift;
            data.setElem(idx, elem);
        }
Example #20
0
        public override void setDataElements(int x, int y, Object obj, DataBuffer data)
        {
            if (x < 0 || y < 0 || x >= this.width || y >= this.height)
            {
                // awt.63=Coordinates are not in bounds
                throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
            }
            switch (dataType)
            {
                case DataBuffer.TYPE_BYTE:
                    byte[] barr = (byte[])obj;
                    for (int i = 0; i < numBands; i++)
                    {
                        setSample(x, y, i, barr[i] & 0xff, data);
                    }
                    break;

                case DataBuffer.TYPE_SHORT:
                case DataBuffer.TYPE_USHORT:
                    short[] sarr = (short[])obj;
                    for (int i = 0; i < numBands; i++)
                    {
                        setSample(x, y, i, sarr[i] & 0xffff, data);
                    }
                    break;

                case DataBuffer.TYPE_INT:
                    int[] iarr = (int[])obj;
                    for (int i = 0; i < numBands; i++)
                    {
                        setSample(x, y, i, iarr[i], data);
                    }
                    break;

                case DataBuffer.TYPE_FLOAT:
                    float[] farr = (float[])obj;
                    for (int i = 0; i < numBands; i++)
                    {
                        setSample(x, y, i, farr[i], data);
                    }
                    break;

                case DataBuffer.TYPE_DOUBLE:
                    double[] darr = (double[])obj;
                    for (int i = 0; i < numBands; i++)
                    {
                        setSample(x, y, i, darr[i], data);
                    }
                    break;
            }
        }
        public override int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
        {
            if (x < 0 || y < 0 || x >= this.width || y >= this.height)
            {
                // awt.63=Coordinates are not in bounds
                throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
            }
            int[] pixel;
            if (iArray == null)
            {
                pixel = new int[this.numBands];
            }
            else
            {
                pixel = iArray;
            }

            for (int i = 0; i < this.numBands; i++)
            {
                pixel[i] = getSample(x, y, i, data);
            }

            return pixel;
        }
Example #22
0
 public override void setSamples(int x, int y, int w, int h, int b, int[] iArray,
         DataBuffer data)
 {
     if (x < 0 || y < 0 || x + w > this.width || y + h > this.height)
     {
         // awt.63=Coordinates are not in bounds
         throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
     }
     int idx = 0;
     for (int i = y; i < y + h; i++)
     {
         for (int j = x; j < x + w; j++)
         {
             setSample(j, i, b, iArray[idx++], data);
         }
     }
 }
 public override void setDataElements(int x, int y, Object obj, DataBuffer data)
 {
     if (x < 0 || y < 0 || x >= this.width || y >= this.height)
     {
         // awt.63=Coordinates are not in bounds
         throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
     }
     switch (getTransferType())
     {
         case DataBuffer.TYPE_BYTE:
             data.setElem(y * scanlineStride + x, ((byte[])obj)[0] & 0xff);
             break;
         case DataBuffer.TYPE_USHORT:
             data.setElem(y * scanlineStride + x, ((short[])obj)[0] & 0xffff);
             break;
         case DataBuffer.TYPE_INT:
             data.setElem(y * scanlineStride + x, ((int[])obj)[0]);
             break;
     }
 }
Example #24
0
 protected WritableRaster(SampleModel sampleModel, DataBuffer dataBuffer,
         Rectangle aRegion, Point sampleModelTranslate,
         WritableRaster parent)
     : base(sampleModel, dataBuffer, aRegion, sampleModelTranslate, parent)
 {
 }
 public override void setSample(int x, int y, int b, int s, DataBuffer data)
 {
     if (x < 0 || y < 0 || x >= this.width || y >= this.height)
     {
         // awt.63=Coordinates are not in bounds
         throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
     }
     int tmp = data.getElem(y * scanlineStride + x);
     tmp &= ~this.bitMasks[b];
     tmp |= (s << this.bitOffsets[b]) & this.bitMasks[b];
     data.setElem(y * scanlineStride + x, tmp);
 }
Example #26
0
 protected WritableRaster(SampleModel sampleModel, DataBuffer dataBuffer,
         Point origin)
     : this(sampleModel, dataBuffer, new Rectangle(origin.x, origin.y,
             sampleModel.width, sampleModel.height), origin, null)
 {
 }
Example #27
0
        public override int[] getSamples(int x, int y, int w, int h, int b, int[] iArray,
                DataBuffer data)
        {
            int[] samples;
            int idx = 0;

            if (iArray == null)
            {
                samples = new int[w * h];
            }
            else
            {
                samples = iArray;
            }

            for (int i = y; i < y + h; i++)
            {
                for (int j = x; j < x + w; j++)
                {
                    samples[idx++] = getSample(j, i, b, data);
                }
            }

            return samples;
        }
        public override int getSample(int x, int y, int b, DataBuffer data)
        {
            if (x < 0 || y < 0 || x >= this.width || y >= this.height || b != 0)
            {
                // awt.63=Coordinates are not in bounds
                throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
            }

            int bitnum = dataBitOffset + x * pixelBitStride;
            int elem = data.getElem(y * scanlineStride + bitnum / dataElementSize);
            int shift = dataElementSize - (bitnum & (dataElementSize - 1)) -
                    pixelBitStride;

            return (elem >> shift) & bitMask;
        }
Example #29
0
 public override void setPixel(int x, int y, int[] iArray, DataBuffer data)
 {
     for (int i = 0; i < numBands; i++)
     {
         setSample(x, y, i, iArray[i], data);
     }
 }
 public override void setDataElements(int x, int y, Object obj, DataBuffer data)
 {
     setSample(x, y, obj, data, 1, 0);
 }
Example #31
0
        public override void setSample(int x, int y, int b, int s, DataBuffer data)
        {
            if (x < 0 || y < 0 || x >= this.width || y >= this.height)
            {
                // awt.63=Coordinates are not in bounds
                throw new java.lang.ArrayIndexOutOfBoundsException("Coordinates are not in bounds"); //$NON-NLS-1$
            }

            data.setElem(bankIndices[b], y * scanlineStride + x +
                           bandOffsets[b], s);
        }
 public override void setPixel(int x, int y, int[] iArray, DataBuffer data)
 {
     setSample(x, y, iArray, data, 2, 0);
 }
Example #33
0
        public override Object getDataElements(int x, int y, Object obj, DataBuffer data)
        {
            switch (dataType)
            {
                case DataBuffer.TYPE_BYTE:
                    {
                        byte[] bdata;

                        if (obj == null)
                        {
                            bdata = new byte[numBands];
                        }
                        else
                        {
                            bdata = (byte[])obj;
                        }

                        for (int i = 0; i < numBands; i++)
                        {
                            bdata[i] = (byte)getSample(x, y, i, data);
                        }

                        obj = bdata;
                        break;
                    }
                case DataBuffer.TYPE_SHORT:
                case DataBuffer.TYPE_USHORT:
                    {
                        short[] sdata;

                        if (obj == null)
                        {
                            sdata = new short[numBands];
                        }
                        else
                        {
                            sdata = (short[])obj;
                        }

                        for (int i = 0; i < numBands; i++)
                        {
                            sdata[i] = (short)getSample(x, y, i, data);
                        }

                        obj = sdata;
                        break;
                    }
                case DataBuffer.TYPE_INT:
                    {
                        int[] idata;

                        if (obj == null)
                        {
                            idata = new int[numBands];
                        }
                        else
                        {
                            idata = (int[])obj;
                        }

                        for (int i = 0; i < numBands; i++)
                        {
                            idata[i] = getSample(x, y, i, data);
                        }

                        obj = idata;
                        break;
                    }
                case DataBuffer.TYPE_FLOAT:
                    {
                        float[] fdata;

                        if (obj == null)
                        {
                            fdata = new float[numBands];
                        }
                        else
                        {
                            fdata = (float[])obj;
                        }

                        for (int i = 0; i < numBands; i++)
                        {
                            fdata[i] = getSampleFloat(x, y, i, data);
                        }

                        obj = fdata;
                        break;
                    }
                case DataBuffer.TYPE_DOUBLE:
                    {
                        double[] ddata;

                        if (obj == null)
                        {
                            ddata = new double[numBands];
                        }
                        else
                        {
                            ddata = (double[])obj;
                        }

                        for (int i = 0; i < numBands; i++)
                        {
                            ddata[i] = getSampleDouble(x, y, i, data);
                        }

                        obj = ddata;
                        break;
                    }
            }

            return obj;
        }
Example #34
0
 protected WritableRaster(SampleModel sampleModel, DataBuffer dataBuffer,
                          Rectangle aRegion, Point sampleModelTranslate,
                          WritableRaster parent) :
     base(sampleModel, dataBuffer, aRegion, sampleModelTranslate, parent)
 {
 }