AlexSavAlexandrov
AlexSavAlexandrov

Reputation: 873

C# Comparing images: Are the images' files the same

I have seen only one solution for comparing images. But this solution checks if EVERYTHING about the images is the same. But I want to check if the images are loaded from the same image file from the resources. I tried with

`"<object>.image == < image from the resources>"`

and

"<object>.Equals(<image from the resources>)"

but it didn't work. The way I know it "==" is used to checks if the two variables or objects are in the same place in the memory (are they the same thing) and "Equals" checks if the two variables or objects have the same values (correct me if I'm wrong). I have investigated why it always returns false.

So, is there a way to check if the images of two objects are loaded from the same image in the resources (are they using the same resource)?

If not, I'll have to make a new object or variable containing the image's name (that's the first thing that comes to my mind), because I want to compare only one thing about the images, not everything. If you have a better solution that you want to share with me, share it! I'll be happy to try a different algorithm.

Upvotes: 2

Views: 370

Answers (1)

Royi Namir
Royi Namir

Reputation: 148524

you should use md5 int the equals function to quick check if its the same file....

Upvotes: 1

Related Questions