What's the reason both Image and Bitmap classes don't implement a custom equality/hashcode logic?
Posted
by devoured elysium
on Stack Overflow
See other posts from Stack Overflow
or by devoured elysium
Published on 2010-05-04T01:43:45Z
Indexed on
2010/05/04
1:48 UTC
Read the original article
Hit count: 310
From MSDN documentation, it seems as both GetHashCode() and Equals() haven't been overriden in Bitmap. Neither have them been overriden in Image. So both classes are using the Object's version of them just compares references. I wasn't too convinced so I decided to fire up Reflector to check it out. It seems MSDN is correct in that matter.
So, is there any special reason why MS guys wouldn't implement "comparison logic", at least for the Bitmap class? I find it is kinda acceptable for Image, as it is an abstract class, but not so much for the Bitmap class. I can see in a lot of situations calculating the hash code can be an expensive operation, but it'd be alright if it used some kind of lazy evaluation (storing the computed hash code integer in a variable a variable, so it wouldn't have to calculate it later again).
When wanting to compare 2 bitmaps, will I have to resort to having to run all over the picture comparing each one of its pixels?
Thanks
© Stack Overflow or respective owner