Пример #1
0
        /// <summary>
        /// Returns a new WritableRaster which shares all or part of this
        /// WritableRaster's DataBuffer.  The new WritableRaster will
        /// possess a reference to the current WritableRaster, accessible
        /// through its getParent() and getWritableParent() methods.
        ///
        /// <para> The parentX, parentY, width and height parameters form a
        /// Rectangle in this WritableRaster's coordinate space, indicating
        /// the area of pixels to be shared.  An error will be thrown if
        /// this Rectangle is not contained with the bounds of the current
        /// WritableRaster.
        ///
        /// </para>
        /// <para> The new WritableRaster may additionally be translated to a
        /// different coordinate system for the plane than that used by the current
        /// WritableRaster.  The childMinX and childMinY parameters give
        /// the new (x, y) coordinate of the upper-left pixel of the
        /// returned WritableRaster; the coordinate (childMinX, childMinY)
        /// in the new WritableRaster will map to the same pixel as the
        /// coordinate (parentX, parentY) in the current WritableRaster.
        ///
        /// </para>
        /// <para> The new WritableRaster may be defined to contain only a
        /// subset of the bands of the current WritableRaster, possibly
        /// reordered, by means of the bandList parameter.  If bandList is
        /// null, it is taken to include all of the bands of the current
        /// WritableRaster in their current order.
        ///
        /// </para>
        /// <para> To create a new WritableRaster that contains a subregion of
        /// the current WritableRaster, but shares its coordinate system
        /// and bands, this method should be called with childMinX equal to
        /// parentX, childMinY equal to parentY, and bandList equal to
        /// null.
        ///
        /// </para>
        /// </summary>
        /// <param name="parentX">    X coordinate of the upper left corner in this
        ///                   WritableRaster's coordinates. </param>
        /// <param name="parentY">    Y coordinate of the upper left corner in this
        ///                   WritableRaster's coordinates. </param>
        /// <param name="w">          Width of the region starting at (parentX, parentY). </param>
        /// <param name="h">          Height of the region starting at (parentX, parentY). </param>
        /// <param name="childMinX">  X coordinate of the upper left corner of
        ///                   the returned WritableRaster. </param>
        /// <param name="childMinY">  Y coordinate of the upper left corner of
        ///                   the returned WritableRaster. </param>
        /// <param name="bandList">   Array of band indices, or null to use all bands. </param>
        /// <returns> a <code>WritableRaster</code> sharing all or part of the
        ///         <code>DataBuffer</code> of this <code>WritableRaster</code>. </returns>
        /// <exception cref="RasterFormatException"> if the subregion is outside of the
        ///                               raster bounds. </exception>
        /// <exception cref="RasterFormatException"> if <code>w</code> or
        ///         <code>h</code>
        ///         is less than or equal to zero, or computing any of
        ///         <code>parentX + w</code>, <code>parentY + h</code>,
        ///         <code>childMinX + w</code>, or
        ///         <code>childMinY + h</code> results in integer
        ///         overflow </exception>
        public virtual WritableRaster CreateWritableChild(int parentX, int parentY, int w, int h, int childMinX, int childMinY, int[] bandList)
        {
            if (parentX < this.MinX_Renamed)
            {
                throw new RasterFormatException("parentX lies outside raster");
            }
            if (parentY < this.MinY_Renamed)
            {
                throw new RasterFormatException("parentY lies outside raster");
            }
            if ((parentX + w < parentX) || (parentX + w > this.Width_Renamed + this.MinX_Renamed))
            {
                throw new RasterFormatException("(parentX + width) is outside raster");
            }
            if ((parentY + h < parentY) || (parentY + h > this.Height_Renamed + this.MinY_Renamed))
            {
                throw new RasterFormatException("(parentY + height) is outside raster");
            }

            SampleModel sm;

            // Note: the SampleModel for the child Raster should have the same
            // width and height as that for the parent, since it represents
            // the physical layout of the pixel data.  The child Raster's width
            // and height represent a "virtual" view of the pixel data, so
            // they may be different than those of the SampleModel.
            if (bandList != null)
            {
                sm = SampleModel_Renamed.CreateSubsetSampleModel(bandList);
            }
            else
            {
                sm = SampleModel_Renamed;
            }

            int deltaX = childMinX - parentX;
            int deltaY = childMinY - parentY;

            return(new WritableRaster(sm, DataBuffer, new Rectangle(childMinX, childMinY, w, h), new Point(SampleModelTranslateX_Renamed + deltaX, SampleModelTranslateY_Renamed + deltaY), this));
        }
Пример #2
0
 /// <summary>
 /// Sets the samples in the specified band for the specified rectangle
 /// of pixels from a double array containing one sample per array element.
 /// An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
 /// not in bounds.
 /// However, explicit bounds checking is not guaranteed. </summary>
 /// <param name="x">        The X coordinate of the upper left pixel location. </param>
 /// <param name="y">        The Y coordinate of the upper left pixel location. </param>
 /// <param name="w">        Width of the pixel rectangle. </param>
 /// <param name="h">        Height of the pixel rectangle. </param>
 /// <param name="b">        The band to set. </param>
 /// <param name="dArray">   The input double sample array.
 /// </param>
 /// <exception cref="NullPointerException"> if dArray is null. </exception>
 /// <exception cref="ArrayIndexOutOfBoundsException"> if the coordinates or
 /// the band index are not in bounds, or if dArray is too small to
 /// hold the input. </exception>
 public virtual void SetSamples(int x, int y, int w, int h, int b, double[] dArray)
 {
     SampleModel_Renamed.SetSamples(x - SampleModelTranslateX_Renamed, y - SampleModelTranslateY_Renamed, w, h, b, dArray, DataBuffer_Renamed);
 }
Пример #3
0
 /// <summary>
 /// Sets a sample in the specified band for the pixel located at (x,y)
 /// in the DataBuffer using a double for input.
 /// An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
 /// not in bounds.
 /// However, explicit bounds checking is not guaranteed. </summary>
 /// <param name="x">        The X coordinate of the pixel location. </param>
 /// <param name="y">        The Y coordinate of the pixel location. </param>
 /// <param name="b">        The band to set. </param>
 /// <param name="s">        The input sample as a double.
 /// </param>
 /// <exception cref="ArrayIndexOutOfBoundsException"> if the coordinates or
 /// the band index are not in bounds. </exception>
 public virtual void SetSample(int x, int y, int b, double s)
 {
     SampleModel_Renamed.SetSample(x - SampleModelTranslateX_Renamed, y - SampleModelTranslateY_Renamed, b, s, DataBuffer_Renamed);
 }
Пример #4
0
 /// <summary>
 /// Sets all samples for a rectangle of pixels from a float array containing
 /// one sample per array element.
 /// An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
 /// not in bounds.
 /// However, explicit bounds checking is not guaranteed. </summary>
 /// <param name="x">        The X coordinate of the upper left pixel location. </param>
 /// <param name="y">        The Y coordinate of the upper left pixel location. </param>
 /// <param name="w">        Width of the pixel rectangle. </param>
 /// <param name="h">        Height of the pixel rectangle. </param>
 /// <param name="fArray">   The input float pixel array.
 /// </param>
 /// <exception cref="NullPointerException"> if fArray is null. </exception>
 /// <exception cref="ArrayIndexOutOfBoundsException"> if the coordinates are not
 /// in bounds, or if fArray is too small to hold the input. </exception>
 public virtual void SetPixels(int x, int y, int w, int h, float[] fArray)
 {
     SampleModel_Renamed.SetPixels(x - SampleModelTranslateX_Renamed, y - SampleModelTranslateY_Renamed, w, h, fArray, DataBuffer_Renamed);
 }
Пример #5
0
 /// <summary>
 /// Sets a pixel in the DataBuffer using a double array of samples for input.
 /// An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
 /// not in bounds.
 /// However, explicit bounds checking is not guaranteed. </summary>
 /// <param name="x">      The X coordinate of the pixel location. </param>
 /// <param name="y">      The Y coordinate of the pixel location. </param>
 /// <param name="dArray"> The input samples in a double array.
 /// </param>
 /// <exception cref="NullPointerException"> if dArray is null. </exception>
 /// <exception cref="ArrayIndexOutOfBoundsException"> if the coordinates are not
 /// in bounds, or if dArray is too small to hold the input. </exception>
 public virtual void SetPixel(int x, int y, double[] dArray)
 {
     SampleModel_Renamed.SetPixel(x - SampleModelTranslateX_Renamed, y - SampleModelTranslateY_Renamed, dArray, DataBuffer_Renamed);
 }
Пример #6
0
 /// <summary>
 /// Sets the data for a rectangle of pixels from a
 /// primitive array of type TransferType.  For image data supported by
 /// the Java 2D API, this will be one of DataBuffer.TYPE_BYTE,
 /// DataBuffer.TYPE_USHORT, DataBuffer.TYPE_INT, DataBuffer.TYPE_SHORT,
 /// DataBuffer.TYPE_FLOAT, or DataBuffer.TYPE_DOUBLE.  Data in the array
 /// may be in a packed format, thus increasing efficiency for data
 /// transfers.
 /// An ArrayIndexOutOfBoundsException may be thrown if the coordinates are
 /// not in bounds, or if inData is not large enough to hold the pixel data.
 /// However, explicit bounds checking is not guaranteed.
 /// A ClassCastException will be thrown if the input object is not null
 /// and references anything other than an array of TransferType. </summary>
 /// <seealso cref= java.awt.image.SampleModel#setDataElements(int, int, int, int, Object, DataBuffer) </seealso>
 /// <param name="x">        The X coordinate of the upper left pixel location. </param>
 /// <param name="y">        The Y coordinate of the upper left pixel location. </param>
 /// <param name="w">        Width of the pixel rectangle. </param>
 /// <param name="h">        Height of the pixel rectangle. </param>
 /// <param name="inData">   An object reference to an array of type defined by
 ///                 getTransferType() and length w*h*getNumDataElements()
 ///                 containing the pixel data to place between x,y and
 ///                 x+w-1, y+h-1.
 /// </param>
 /// <exception cref="NullPointerException"> if inData is null. </exception>
 /// <exception cref="ArrayIndexOutOfBoundsException"> if the coordinates are not
 /// in bounds, or if inData is too small to hold the input. </exception>
 public virtual void SetDataElements(int x, int y, int w, int h, Object inData)
 {
     SampleModel_Renamed.SetDataElements(x - SampleModelTranslateX_Renamed, y - SampleModelTranslateY_Renamed, w, h, inData, DataBuffer_Renamed);
 }