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


C# Files.GetSample方法代码示例

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


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

示例1: GetValues

        public override IEnumerable<PointF> GetValues(Files.LocatorFile file, Point p)
        {
            int fromInclusive;
            int toInclusive;
            var coordPairList = new List<PointF>();

            if (Math.Abs(InitialPoint.X - p.X) > Math.Abs(InitialPoint.Y - p.Y))
            {
                fromInclusive = InitialPoint.X > p.X ? p.X : InitialPoint.X;
                toInclusive = InitialPoint.X > p.X ? InitialPoint.X : p.X;

                fromInclusive = fromInclusive > file.Width ? file.Width : fromInclusive;
                fromInclusive = fromInclusive < 0 ? 0 : fromInclusive;

                toInclusive = toInclusive > file.Width ? file.Width : toInclusive;
                toInclusive = toInclusive < 0 ? 0 : toInclusive;

                for (int i = fromInclusive; i < toInclusive; i++)
                {
                    var pointToGetSample = new Point(i, GeometryHelper.GetY(InitialPoint, p, i));
                    if (pointToGetSample.X < 0 || pointToGetSample.X > file.Width ||
                        pointToGetSample.Y < 0 || pointToGetSample.Y > file.Height)
                    {
                        continue;
                    }

                    try
                    {
                        coordPairList.Add(new PointF(i, (float)file.GetSample(pointToGetSample).ToFileSample(file.Properties.Type, file.Header.BytesPerSample)));
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }


            }
            else
            {
                fromInclusive = InitialPoint.Y > p.Y ? p.Y : InitialPoint.Y;
                toInclusive = InitialPoint.Y > p.Y ? InitialPoint.Y : p.Y;

                fromInclusive = fromInclusive > file.Height ? file.Height : fromInclusive;
                fromInclusive = fromInclusive < 0 ? 0 : fromInclusive;

                toInclusive = toInclusive > file.Height ? file.Height : toInclusive;
                toInclusive = toInclusive < 0 ? 0 : toInclusive;

                for (int i = fromInclusive; i < toInclusive; i++)
                {
                    var pointToGetSample = new Point(GeometryHelper.GetX(InitialPoint, p, i), i);
                    if (pointToGetSample.X < 0 || pointToGetSample.X >= file.Width ||
                        pointToGetSample.Y < 0 || pointToGetSample.Y >= file.Height)
                    {
                        continue;
                    }

                    coordPairList.Add(new PointF(i, file.GetSample(pointToGetSample).ToFileSample(file.Properties.Type, file.Header.BytesPerSample)));
                }

            }          
           
            return coordPairList;
        }
开发者ID:worstward,项目名称:rlviewer,代码行数:65,代码来源:LinearSection.cs


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