Uniquely identifying Images from Resource files

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
 
K

Kevin Spencer

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
 
S

Sean Aitken

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top