Figure 1: An interface file for SWIG describing the structures and functions of Image Magick
%module Image %{ /* Include appropriate header files. */ #include <magick.h> %} %typemap ( memberin ) char [ANY] { strncpy ( $target, $source, $dim0 ); } typedef struct _ImageInfo { char *filename; %addmethods { ImageInfo () { ImageInfo* info; info = malloc ( sizeof ( ImageInfo ) ); GetImageInfo(info); return info; } ~ImageInfo() { DestroyImageInfo ( self ); } } } ImageInfo; typedef struct _Image { char filename[MaxTextExtent]; unsigned int columns, rows, depth; float x_resolution, y_resolution; %addmethods { /* * Add a destructor */ ~Image() { DestroyImage ( self ); } /* Image utilities routines. */ Image *Blur(double inDouble) { return BlurImage(self,inDouble); } Image *Edge(double inDouble) { return EdgeImage(self,inDouble); } Image *Emboss() { return EmbossImage(self); } Image *Flip() { return FlipImage(self); } Image *Flop() { return FlopImage(self); } Image *Swirl(double angle) { return SwirlImage(self,angle); } Image *Wave ( double amplitude, double frequency ) { return WaveImage ( self, amplitude, frequency ); } unsigned int IsGray ( ) { return IsGrayImage(self); } unsigned int Write(ImageInfo *inInfo) { return WriteImage(inInfo,self); } } } Image; /* * Other utility routines */ Image* ReadImage ( ImageInfo * inInfo );