本文整理汇总了C#中Iterator.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# Iterator.Invoke方法的具体用法?C# Iterator.Invoke怎么用?C# Iterator.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Iterator
的用法示例。
在下文中一共展示了Iterator.Invoke方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformIterativeComparison
private static void PerformIterativeComparison(Bitmap referenceImage, Bitmap testImage, Rectangle bounds, bool generateDiffImage, out Bitmap diffImage, Iterator iterator)
{
if (referenceImage.Size != testImage.Size)
{
diffImage = null;
return;
}
double root3 = Math.Sqrt(3);
int width = referenceImage.Width;
int height = referenceImage.Height;
int count = width*height;
var rect = new Rectangle(0, 0, width, height);
diffImage = generateDiffImage ? new Bitmap(width, height) : null;
unsafe
{
var referenceBits = referenceImage.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
try
{
var testBits = testImage.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
try
{
int* testData = (int*) testBits.Scan0;
int* referenceData = (int*) referenceBits.Scan0;
for (int n = 0; n < count; n++)
{
var x = n%width;
var y = n/width;
var referenceValue = ToRgbVector(referenceData[n]);
var testValue = ToRgbVector(testData[n]);
var delta = 0.0;
if (bounds.Contains(x, y))
{
delta = (referenceValue - testValue).Magnitude/root3;
iterator.Invoke(x, y, n, delta);
}
if (generateDiffImage)
{
var v = (int) (Math.Min(255, Math.Max(0, delta)));
diffImage.SetPixel(x, y, Color.FromArgb(v, v, v));
}
}
}
finally
{
testImage.UnlockBits(testBits);
}
}
finally
{
referenceImage.UnlockBits(referenceBits);
}
}
}