Esempio n. 1
0
        /// <summary>
        /// Reads the value from the array to a raster.
        /// </summary>
        /// <param name="stripBytes">The strip bytes.</param>
        /// <param name="byteIndex">The zero-based byte index in the strip array.</param>
        /// <param name="bitIndex">The zero-based bit index in the strip array.</param>
        /// <param name="raster">The raster.</param>
        /// <param name="rowIndex">The zero-based row index in the raster.</param>
        /// <param name="columnIndex">The zero-based column index in the raster.</param>
        /// <param name="bandIndex">The zero-based band index in the raster.</param>
        private void ReadValue(Byte[] stripBytes, ref Int32 byteIndex, ref Int32 bitIndex, IRaster raster, Int32 rowIndex, Int32 columnIndex, Int32 bandIndex)
        {
            if (_radiometricResolution < 8 && 8 % _radiometricResolution == 0)
            {
                bitIndex -= _radiometricResolution;
                raster.SetValue(rowIndex, columnIndex, bandIndex, Convert.ToByte(stripBytes[byteIndex] >> bitIndex));

                if (bitIndex == 0)
                {
                    bitIndex = 8;
                    byteIndex++;
                }
            }
            else if (_radiometricResolution == 8)
            {
                raster.SetValue(rowIndex, columnIndex, bandIndex, Convert.ToByte(stripBytes[byteIndex]));
                byteIndex++;
            }
            else if (_radiometricResolution == 16)
            {
                raster.SetValue(rowIndex, columnIndex, bandIndex, EndianBitConverter.ToUInt16(stripBytes, byteIndex, _byteOrder));
                byteIndex += 2;
            }
            else if (_radiometricResolution == 32)
            {
                raster.SetValue(rowIndex, columnIndex, bandIndex, EndianBitConverter.ToUInt32(stripBytes, byteIndex, _byteOrder));
                byteIndex += 4;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a raster image.
        /// </summary>
        /// <param name="other">The other raster image.</param>
        /// <returns>The produced raster image matching <paramref name="other"/>.</returns>
        /// <exception cref="System.ArgumentNullException">The other raster is null.</exception>
        public IRaster CreateRaster(IRaster other)
        {
            if (other == null)
            {
                throw new ArgumentNullException("other", "The other raster is null.");
            }

            IRaster raster = CreateRaster(other.Format, other.NumberOfBands, other.NumberOfRows, other.NumberOfColumns, other.RadiometricResolution, other.Mapper);

            switch (raster.Format)
            {
            case RasterFormat.Integer:
                for (Int32 bandIndex = 0; bandIndex < raster.NumberOfBands; bandIndex++)
                {
                    for (Int32 rowIndex = 0; rowIndex < raster.NumberOfRows; rowIndex++)
                    {
                        for (Int32 columnIndex = 0; columnIndex < raster.NumberOfColumns; columnIndex++)
                        {
                            raster.SetValue(rowIndex, columnIndex, bandIndex, raster.GetValue(rowIndex, columnIndex, bandIndex));
                        }
                    }
                }
                break;

            case RasterFormat.Floating:
                for (Int32 bandIndex = 0; bandIndex < raster.NumberOfBands; bandIndex++)
                {
                    for (Int32 rowIndex = 0; rowIndex < raster.NumberOfRows; rowIndex++)
                    {
                        for (Int32 columnIndex = 0; columnIndex < raster.NumberOfColumns; columnIndex++)
                        {
                            raster.SetFloatValue(rowIndex, columnIndex, bandIndex, raster.GetFloatValue(rowIndex, columnIndex, bandIndex));
                        }
                    }
                }
                break;
            }

            return(raster);
        }
Esempio n. 3
0
 /// <summary>
 /// Sets the spectral value at a specified index.
 /// </summary>
 /// <param name="rowIndex">The zero-based row index of the value.</param>
 /// <param name="columnIndex">The zero-based column index of the value.</param>
 /// <param name="bandIndex">The zero-based band index of the value.</param>
 /// <param name="spectralValue">The spectral value.</param>
 protected override void ApplySetValue(Int32 rowIndex, Int32 columnIndex, Int32 bandIndex, UInt32 spectralValue)
 {
     _source.SetValue(_rowIndex + rowIndex, _columnIndex + columnIndex, bandIndex, spectralValue);
 }
Esempio n. 4
0
 /// <summary>
 /// Sets a spectral value at a specified row and column index.
 /// </summary>
 /// <param name="rowIndex">The zero-based column index of the value.</param>
 /// <param name="columnIndex">The zero-based row index of the value.</param>
 /// <param name="value">The spectral value.</param>
 /// <exception cref="System.NotSupportedException">The raster is not writable.</exception>
 /// <exception cref="System.ArgumentOutOfRangeException">
 /// The row index is less than 0.
 /// or
 /// The row index is equal to or greater than the number of rows.
 /// or
 /// The column index is less than 0.
 /// or
 /// the column index is equal to or greater than the number of columns.
 /// </exception>
 public void SetValue(Int32 rowIndex, Int32 columnIndex, UInt32 value)
 {
     _raster.SetValue(rowIndex, columnIndex, _bandIndex, value);
 }