ERIK518

Comapre

Jan 3rd, 2014
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.62 KB | None | 0 0
  1.         private void Compare()
  2.         {
  3.             int flag = 0;
  4.             int count1 = 0;
  5.             int count2 = 0;
  6.             string img1_ref, img2_ref;
  7.             Bitmap img1 = new Bitmap(@"c:\Fotky\Obrazok1.bmp");
  8.             Bitmap img2 = new Bitmap(@"c:\Fotky\Obrazok1por.bmp"); // originál
  9.             if (img1.Width == img2.Width && img1.Height == img2.Height)
  10.             {
  11.                 for (int i = 0; i < img1.Width; i++)
  12.                 {
  13.                     for (int j = 0; j < img1.Height; j++)
  14.                     {
  15.                         img1_ref = img1.GetPixel(i, j).ToString();
  16.                         img2_ref = img2.GetPixel(i, j).ToString();
  17.                         if (img1_ref != img2_ref)
  18.                         {
  19.                             count2++;
  20.                             flag = 1;
  21.                             break;
  22.                         }
  23.                         count1++;
  24.                     }
  25.                 }
  26.                 if (flag == 1)
  27.                 {
  28.                     Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
  29.  
  30.                     Graphics graphics = Graphics.FromImage(printscreen as Image);
  31.  
  32.                     graphics.CopyFromScreen(17, 231, 1885, 1054, printscreen.Size);
  33.  
  34.                     printscreen.Save(@"C:\Fotky\Obrazok1.bmp");
  35.                     System.Threading.Thread.Sleep(650);
  36.                     Compare();
  37.                 }
  38.                 else
  39.                 {
  40.                     click6();
  41.                 }
  42.             }
  43.             this.Dispose();
  44.         }
Advertisement
Add Comment
Please, Sign In to add comment