本文整理匯總了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;
}