當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。