I have more than 3000 image, 1500 small image & 1500 large image.
i want to check if small image is the same as large image as an example large image & small image.
I use the following code for check images but return false result for all images ( same or not ) can anyone help me to solve this?
public static bool IsEqual(this BitmapImage image1, BitmapImage image2)
{
if (image1 == null || image2 == null)
{
return false;
}
return image1.ToBytes().SequenceEqual(image2.ToBytes());
}
public static byte[] ToBytes(this BitmapImage image)
{
byte[] data = new byte[] { };
if (image != null)
{
try
{
var encoder = new BmpBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(image));
using (MemoryStream ms = new MemoryStream())
{
encoder.Save(ms);
data = ms.ToArray();
}
return data;
}
catch (Exception ex)
{
}
}
return data;
}