C# 比较图像:图像是吗?文件相同
我只见过一种比较图像的解决方案。但此解决方案会检查图像的所有内容是否相同。但我想检查图像是否是从资源中的同一图像文件加载的。 我尝试使用
`"<object>.image == < image from the resources>"`
and
"<object>.Equals(<image from the resources>)"
但没有成功。我知道“==”用于检查两个变量或对象是否位于内存中的同一位置(它们是否相同),“等于”检查两个变量或对象是否具有相同的值(如果我错了请纠正我)。我研究过为什么它总是返回 false。
那么,有没有办法检查两个对象的图像是否从资源中的同一个图像加载(它们是否使用相同的资源)?
如果没有,我将不得不创建一个包含图像名称的新对象或变量(这是我想到的第一件事),因为我只想比较图像的一件事,而不是所有内容。如果您有更好的解决方案想与我分享,请分享!我很乐意尝试不同的算法。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你应该使用 md5 int equals 函数来快速检查它是否是同一个文件......
you should use md5 int the equals function to quick check if its the same file....