Genesis/Terminus

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
*void

Genesis/Terminus

Post 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.)
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post 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().
Post Reply