本文整理汇总了C#中System.Files.GetArea方法的典型用法代码示例。如果您正苦于以下问题:C# Files.GetArea方法的具体用法?C# Files.GetArea怎么用?C# Files.GetArea使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Files
的用法示例。
在下文中一共展示了Files.GetArea方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResampleImage
public override byte[] ResampleImage(Files.LocatorFile file, System.Drawing.Rectangle area)
{
float[] image = new float[area.Width * area.Height];
float[] imageArea = file.GetArea(area).ToArea<float>(file.Header.BytesPerSample);
int toInclusiveX = area.Location.X + area.Width;
toInclusiveX = toInclusiveX > file.Width ? file.Width : toInclusiveX;
int toInclusiveY = area.Location.Y + area.Height;
toInclusiveY = toInclusiveY > file.Height ? file.Height : toInclusiveY;
int counter = 0;
var rcsSolution = GetRcsSolution(area);
var amplitudeSolution = GetAmplitudeSolution(area);
Parallel.For(area.Location.X, toInclusiveX, (i, loopState) =>
{
for (int j = area.Location.Y; j < toInclusiveY; j++)
{
var oldAmplVal = imageArea[(j - area.Y) * area.Width + (i - area.X)];
var newAmplVal = (float)amplitudeSolution[i - area.X, j - area.Y];
var newRcsVal = (float)rcsSolution[i - area.X, j - area.Y];
var diff = oldAmplVal / newAmplVal * newRcsVal;
diff = diff < 0 ? 0 : diff;
image[(j - area.Location.Y) * area.Width + (i - area.Location.X)] = diff;
}
System.Threading.Interlocked.Increment(ref counter);
OnProgressReport((int)(counter / Math.Ceiling((double)(toInclusiveX - area.Location.X)) * 100));
if (OnCancelWorker())
{
loopState.Break();
}
});
if (Cancelled)
{
return null;
}
byte[] imageB = new byte[image.Length * 4];
Buffer.BlockCopy(image, 0, imageB, 0, imageB.Length);
return imageB;
}