Here I have found and tweaked a little code snippet. It is written in c#.
In this code, we are converting two Image objects into Base64 String
. By Comparing the Base64 string
together , we will know that whether images are same. The Code is below.
public static bool ImageCompareString(Image firstImage, Image secondImage)
{
var ms = new MemoryStream();
firstImage.Save(ms, ImageFormat.Png);
String firstBitmap = Convert.ToBase64String(ms.ToArray());
ms.Position = 0;
secondImage.Save(ms, ImageFormat.Png);
String secondBitmap = Convert.ToBase64String(ms.ToArray());
if (firstBitmap.Equals(secondBitmap))
{
return true;
}
else
{
return false;
}
}