Page 1 of 1


Posted: 2007-01-18T15:47:36-07:00
by *void
I am unclear about the purpose or usage of the MagickWandGenesis / MagickWandTerminus methods.

The only examples of usage are brief self-contained procedures, where Genesis is used at the start and Terminus at the end. Simple enough to understand that they bracket a body of Magick code. However, I will be using the API in a more complex MS Windows environment, with multiple windows, called modules, and quite possibly multiple execution threads. I will have modules that act on images in passed wands, and also create and destroy local wands.

It isn't clear whether there should be a single Genesis/Terminus bracket for the entire application, for a window, or for a module of code. Or all of the above. It isn't clear whether a local Genesis / Terminus bracket establishes a new context and if so, whether wands passed into that context are valid.

A little guidance would be appreciated.

I tried to read the source for clues, but found it over my head. :oops: (Not familiar with splay trees and don't think I want to know. Also, my understanding of C is somewhat limited. I use a different language.)

Posted: 2007-01-18T17:32:34-07:00
by magick
Call MagickWandGenesis() to create the MagickWand environment and MagickWandTerminus() when you are completely done (e.g. when exiting your program). In a multi-threaded environment you would not want to call MagickWandTerminus() until all the threads are completed. Without these calls, the MagickWand environment is destroyed each time the wand count returns to zero (you create a bunch of wands then destroy them all). This is certainly problematic for threaded code since another thread may depend on the environment and crash unexpectedly. By calling MagickWandGenesis() it assures the enviroment stays until the program exits or you explicitly call MagickWandTerminus().