当前位置: 首页>>代码示例>>C#>>正文


C# IRaster.Read方法代码示例

本文整理汇总了C#中IRaster.Read方法的典型用法代码示例。如果您正苦于以下问题:C# IRaster.Read方法的具体用法?C# IRaster.Read怎么用?C# IRaster.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRaster的用法示例。


在下文中一共展示了IRaster.Read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetValues

        /// <summary>
        /// Get the pixel values in a region of the input raster.
        /// </summary>
        /// <param name="tlCorner"></param>
        /// <param name="brCorner"></param>
        /// <param name="raster"></param>
        /// <returns></returns>
        public static double[,] GetValues(Position tlCorner, Position brCorner, IRaster raster)
        {
            int colCount = brCorner.Column - tlCorner.Column + 1;
            int rowCount = brCorner.Row - tlCorner.Row + 1;

            IPnt regionSize = new PntClass();
            regionSize.SetCoords(colCount, rowCount);
            IPixelBlock pixelBlock = raster.CreatePixelBlock(regionSize);
            IPnt tl = new PntClass();
            tl.SetCoords(tlCorner.Column, tlCorner.Row);
            raster.Read(tl, pixelBlock);

            double[,] values = new double[colCount, rowCount];
            for (int x = 0; x < colCount; x++)
            {
                for (int y = 0; y < rowCount; y++)
                {
                    values[x, y] = Convert.ToDouble(pixelBlock.GetVal(0, x, y));
                }
            }
            return values;
        }
开发者ID:nazzal88,项目名称:ares,代码行数:29,代码来源:Raster.cs

示例2: WriteEdits

        /// <summary>
        /// Write edits to the input raster.
        /// </summary>
        /// <param name="raster">Raster of raster layer to be edited.</param>
        /// <param name="edits">Pixel collection that contains edited pixels.</param>
        private static void WriteEdits(IRaster raster, PixelCollection edits)
        {
            IRasterProps rasterProps = (IRasterProps)raster;

            int minRow = rasterProps.Height - 1;
            int maxRow = 0;
            int minCol = rasterProps.Width - 1;
            int maxCol = 0;

            for (int i = 0; i < edits.Count; i++)
            {
                #region Get the extent of the edition region

                Position cellPos = edits[i].Position;

                if (cellPos.Row > maxRow)
                {
                    maxRow = cellPos.Row;
                }

                if (cellPos.Row < minRow)
                {
                    minRow = cellPos.Row;
                }

                if (cellPos.Column > maxCol)
                {
                    maxCol = cellPos.Column;
                }

                if (cellPos.Column < minCol)
                {
                    minCol = cellPos.Column;
                }

                #endregion
            }

            IPnt pos = new PntClass();
            pos.SetCoords(maxCol - minCol + 1, maxRow - minRow + 1);
            IPixelBlock pixelBlock = raster.CreatePixelBlock(pos);
            pos.SetCoords(minCol, minRow);
            raster.Read(pos, pixelBlock);

            // Set new values
            IPixelBlock3 pixelBlock3 = (IPixelBlock3)pixelBlock;
            Array pixels = (Array)pixelBlock3.get_PixelData(0);

            for (int i = 0; i < edits.Count; i++)
            {
                object value = null;
                Raster.CSharpValue2PixelValue(edits[i].NewValue, rasterProps.PixelType, out value);

                pixels.SetValue(value,
                                edits[i].Position.Column - minCol,
                                edits[i].Position.Row - minRow);
            }

            pixelBlock3.set_PixelData(0, (System.Object)pixels);
            IRasterEdit rasterEdit = (IRasterEdit)raster;
            rasterEdit.Write(pos, (IPixelBlock)pixelBlock3);
        }
开发者ID:nazzal88,项目名称:ares,代码行数:67,代码来源:Raster.cs

示例3: GetValue

        /// <summary>
        /// Gets value of pixel at the specified position.
        /// </summary>
        /// <param name="pos"></param>
        /// <param name="raster"></param>
        /// <returns></returns>
        public static double GetValue(Position pos, IRaster raster)
        {
            IPnt regionSize = new PntClass();
            regionSize.SetCoords(1, 1);
            IPixelBlock pixelBlock = raster.CreatePixelBlock(regionSize);
            IPnt tl = new PntClass();
            tl.SetCoords(pos.Column, pos.Row);
            raster.Read(tl, pixelBlock);

            return Convert.ToDouble(pixelBlock.GetVal(0, 0, 0));
        }
开发者ID:nazzal88,项目名称:ares,代码行数:17,代码来源:Raster.cs


注:本文中的IRaster.Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。