Create bitmap to compare two images by pixel
<p>I am trying to compare two images by pixel.
I have searched on Google about bitmap but I did not clear with it.</p>

<p>My code is showing error <code>Parameter is not valid</code>.</p>

<p>I have try this;</p>

<p>var a = new Bitmap(imageurl);</p>

<p>but it does not work.</p>

<p>I am also refer this site for image comparison:</p>

<p><a href="http://www.c-sharpcorner.com/uploadfile/prathore/image-comparison-using-C-Sharp/" rel="nofollow">http://www.c-sharpcorner.com/uploadfile/prathore/image-comparison-using-C-Sharp/</a></p>

<p>What I have tried:</p>

<p>but showing error on this line <code>parameter is not valid</code>.</p>

<pre><code>var img1 = new Bitmap(fileone);
var img2 = new Bitmap(filetwo);
</code></pre>

<p>I have store path in this two variable like this,</p>

<pre><code>fileone=C:\image\a.jpg:
filetwo=c:\image\b.jpg;

var img1 = new Bitmap(fileone);
var img2 = new Bitmap(filetwo);

if (img1.Width == img2.Width &amp;&amp; img1.Height == img2.Height)
{
   for (int i = 0; i &lt; img1.Width; i++)
   {
       for (int j = 0; j &lt; img1.Height; j++)
       {
           img1_ref = img1.GetPixel(i, j).ToString();
           img2_ref = img2.GetPixel(i, j).ToString();

           if (img1_ref != img2_ref)
           {
              count2++;
              flag = false;
              break;
           }

           count1++;
        }
        // progressBar1.Value++;
    }

    if (flag == false)
       Response.Write("Sorry, Images are not same , " + count2 + " wrong pixels found");
    else
       Response.Write(" Images are same , " + count1 + " same pixels found and " + count2 + " wrong pixels found");
}
else
   Response.Write("can not compare this images");

this.Dispose();
</code></pre>
