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'在靜態屬性,靜態方法或靜態字段初始值設定項中無效。
怎麼回事,我該如何解決這個問題?