Example:
export unsigned int IsGIF(const unsigned char *magick,unsigned int
length)
{
[ test image header for supported magick ... ]
}
export Image *ReadGIFImage(const ImageInfo *image_info)
{
[ decode the image ... ]
}
export unsigned int WriteGIFImage(const ImageInfo *image_info,Image
*image)
{
[ encode the image ... ]
}
#include <stdio.h>
int main( void )
{
struct MagickInfo* info;
info = SetMagickInfo("GIF");
if ( info == (MagickInfo*)NULL )
exit(1);
info->decoder = ReadGIFImage;
info->encoder = WriteGIFImage;
info->magick = IsGIF;
info->adjoin = False;
info->description = AllocateString("CompuServe graphics
interchange format");
/* Add MagickInfo structure to list */
RegisterMagickInfo(info);
info = GetMagickInfo("GIF");
[ do something with info ... ]
ListMagickInfo( stdout );
return;
}
The members of the MagickInfo structure are shown in the following table:
|
|
|
tag | const char * | Magick string (e.g. "GIF") to call this format. |
decoder | Image *(*decoder)(const ImageInfo *) | Function to decode image data and return ImageMagick Image. |
encoder | unsigned int (*encoder)(const ImageInfo *, Image *) | Function to encode image data with options passed via ImageInfo and image represented by Image. |
magick | unsigned int (*magick)(const unsigned char *,const unsigned int) | Function to test file magick based on bytes starting at the specified pointer with specified size. Returns non-zero (True) if file type is supported. |
adjoin | unsigned int | Set to non-zero (True) if this file format supports multi-frame images. |
blob_support | unsigned int | Set to non-zero (True) if the encoder and decoder for this format supports operating arbitrary BLOBs (rather than only disk files). |
raw | unsigned int | Image format does not contain size (must be specified in ImageInfo). |
description | const char * | Long form image format description (e.g. "CompuServe graphics interchange format"). |
data | void * | User specified data. A way to pass any sort of data structure to the endoder/decoder. To set this, GetMagickInfo() must be called to first obtain a pointer to the registered structure since it can not be set via a RegisterMagickInfo() parameter. |
previous | MagickInfo | Previous MagickInfo struct in linked-list. NULL if none. |
next | MagickInfo | Next MagickInfo struct in linked-list. NULL if none. |