Uniquely identifying Images from Resource files

  • Thread starter Thread starter Sean Aitken
  • Start date Start date
S

Sean Aitken

Good morning,

Does anyone know of a way to extract a unique hashcode or identifier
from an Image that comes from a typed Resource file? I am trying to
optimize a routine that takes the actual image object itself.
Currently, the Equals operator seems to compare the image pixel for
pixel to determine equality. This VERY slow! Maybe just a way to
compare references would be nice.. (Since the Image exposed from the
Resource file exists as a single reference).

Ultimately, I would like a way to map these ID's to the actual image
itself (ultimately mapping unique instances to an ImageList).

Any pointers? have I confused everyone?
:)

Thanks!
-Sean
 
The only way to be sure that 2 images are identical is to compare them pixel
by pixel.This is because 2 images may have all the same characteristics
otherwise, but still have different pixel values.

And yes, I do have a "pointer" - use pointers to compare the images. Here's
an excellent article on the subject:

http://www.bobpowell.net/lockingbits.htm

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
Thanks, Kevin!

Reflecting into the Image class I see no override on the GetHashcode
method... so I can't use GetHashcode. I'll take a look at using the
pointer to compare. For the situation I'm in (and to stay away from
the unmanaged business), I think I'm going to create a dictionary of
keys to images that can be used for specifying images in my list.

Cheers!
-Sean
 
Back
Top