本文整理汇总了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;
}