public static void Main()
{
Stream s1 = this.GetType().Assembly.GetManifestResourceStream("WindowsApplication1.sudhir.jpg");
Stream s2 = this.GetType().Assembly.GetManifestResourceStream("WindowsApplication1.sunil.jpg");
Bitmap img1 = new Bitmap(s1);
Bitmap img2 = new Bitmap(s2);
if (img1.Size != img2.Size)
{
Console.Error.WriteLine("Images are of different sizes");
return;
}
float diff = 0;
for (int y = 0; y < img1.Height; y++)
{
for (int x = 0; x < img1.Width; x++)
{
diff += (float)Math.Abs(img1.GetPixel(x, y).R - img2.GetPixel(x, y).R)/255;
diff += (float)Math.Abs(img1.GetPixel(x, y).G - img2.GetPixel(x, y).G)/255;
diff += (float)Math.Abs(img1.GetPixel(x, y).B - img2.GetPixel(x, y).B)/255;
}
}
Console.WriteLine("diff: {0} %", 100 * diff/(img1.Width * img1.Height * 3));
在这里,我尝试匹配两个图像,并发现它们的区别有效的,但我得到这个错误关键字“这个”是不是一个静态属性,静态方法或静态字段初始
关键字'this'在静态属性,静态方法或静态字段初始值设定项中无效。
怎么回事,我该如何解决这个问题?