On Wed, Apr 9, 2008 at 4:35 AM, Torsten Neuer <[EMAIL PROTECTED]> wrote:
> Hello everybody,
> I am currently updating an older plugin (one that is not in the distribution
> nor in the registry anymore) in order to bring it back to life (and, well,
> maybe learn something about Gimp programming as well).
> The plugin although it worked quite well, seemed never to have been finished.
> Now, there is a random function in this plugin, which according to
> documentation, would require a random number seed that is unique for every
> image that is going to be processed, i.e. the result of the random function
> should be identical for any identical image. This, however, has not been
> implemented as such in the old files.
> Now my idea was to use some sort or CRC on the drawable to get a seed for the
> random number generator, that would match these requirements.
> Since I haven't been able to find a function within the libraries that I
> use as a starting point (and of course I do not want to re-invent the wheel),
> my question is, if there is such a function that would provide an identical
> value for any identical image - or would I have to write a kind of pre-filter
> in order to generate that value ?
What you are talking about is a hash function. There is a string
hasher in GLib that should do what you want.
However, be aware,
the criteria 'a random number seed that is unique for every image that
is going to be processed,' cannot be fulfilled in an absolute way.
With a hash value of 32bits, that's > 4 billion possible hashes.
Practically speaking, you are unlikely to encounter a hash collision*
unless the amount of images in the set you're processing gets very
large, you should be aware that it is always possible though.
* when two different data produce the same hash value.
> Thank you very much for listening,
> Gimp-developer mailing list
Gimp-developer mailing list