>K [ 1 S 2 ImageMagick MagickInfo StructureV<> 
H



.ImageMagick MagickInfo Structure

GThe MagickInfo structure is used by ImageMagick to register support forNan Image format. The MagickInfo structure is allocated with default parametersFby calling SetMagickInfo().YImage formats are registered by calling RegisterMagickInfo()Gwhich adds the initial structure to a linked list (at which point it isFowned by the list). A pointer to the structure describing a format mayRbe obtained by calling GetMagickInfo().PPass the argument NULL to obtain the first member of this list. A human-readableGlist of registered image formats may be printed to a file descriptor byEcalling ListMagickInfo().G

Support for formats may be provided as a module which is part of theHImageMagick library, provided by a module which is loaded dynamically atFrun-time, or directly by the linked program. Users of ImageMagick willFnormally want to create a loadable-module, or support encode/decode of3an image format directly from within their program.

Sample Module:

GThe following shows sample code for a module called "GIF" (gif.c). NoteOthat the names of the Register and Unregister call-back routines are calculated[at run-time, and therefore must follow the rigid naming scheme RegisterFORMATImageQand UnregisterFORMATImage, respectively, where FORMAT is the upper-casedname of the module file:

/* Read image */=
Image *ReadGIFImage(const ImageInfo *image_info)
{,
  [ decode the image ... ]
}

/* Write image */Q
unsigned int WriteGIFImage(const ImageInfo *image_info,Image *image)
{,
  [ encode the image ... ]
}B

/* Module call-back to register support for formats */(
void RegisterGIFImage(void)
{
  MagickInfo'
    *entry;.

  entry=SetMagickInfo("GIF");0
  entry->decoder=ReadGIFImage;1
  entry->encoder=WriteGIFImage;Q
  entry->description=AllocateString("CompuServe graphics interchangeformat");8
  entry->module=AllocateString("GIF");.
  RegisterMagickInfo(entry);1
  entry=SetMagickInfo("GIF87");0
  entry->decoder=ReadGIFImage;1
  entry->encoder=WriteGIFImage;(
  entry->adjoin=False;'
  entry->description=J
    AllocateString("CompuServe graphics interchangeformat (version 87a)");8
  entry->module=AllocateString("GIF");.
  RegisterMagickInfo(entry);
}D

/* Module call-back to unregister support for formats */1
Export void UnregisterGIFImage(void)
{0
  UnregisterMagickInfo("GIF");2
  UnregisterMagickInfo("GIF87");
}

Sample Application Code

IImage format support provided within the user's application does not needHto implement the RegisterFORMATImage and UnregisterFORMATImage call-backLroutines. Instead, the application takes responsibility for the registrationitself. An example follows:

/* Read image */=
Image *ReadGIFImage(const ImageInfo *image_info)
{,
  [ decode the image ... ]
}

/* Write image */Q
unsigned int WriteGIFImage(const ImageInfo *image_info,Image *image)
{,
  [ encode the image ... ]
}!

#include <stdio.h>
int main( void )
{,
  struct MagickInfo* info;/

  info = SetMagickInfo("GIF");3

  if ( info == (MagickInfo*)NULL )(
    exit(1);0

  info->decoder = ReadGIFImage;2
  info->encoder = WriteGIFImage;/
  info->adjoin  = False;F
  info->description = AllocateString("CompuServe graphicsinterchange format");:
  /* Add MagickInfo structure to list */-
  RegisterMagickInfo(info);/

  info = GetMagickInfo("GIF");2
  [ do something with info ... ],

  ListMagickInfo( stdout );
  return;
}

$MagickInfo Structure Definition

IThe members of the MagickInfo structure are shown in the following table:
 .6PNH[DMH`IA=AM
MagickInfo Structure Members

Member


Type

#
Description

adjoinunsigned intSet to non-zero (True) if this file format supports multi-frame images.
blob_supportunsigned intSet to non-zero (True) if the encoder and decoder for this format supports@operating on arbitrary BLOBs (rather than only disk files).
datavoid *User specified data. A way to pass any sort of data structure to theXendoder/decoder. To set this, GetMagickInfo()Jmust be called to first obtain a pointer to the registered structure sincevit can not be set via a RegisterMagickInfo()parameter.
decoderImage *(*decoder)(const ImageInfo*)Function to decode image data and return ImageMagick Image.
descriptionchar *Long form image format description (e.g. "CompuServe graphics interchangeformat").
encoderunsigned int (*encoder)(const ImageInfo*, Image *)Function to encode image data with options passed via ImageInfo=and image represented by Image.
modulechar *Name of module (e.g. "GIF") which registered this format. Set to NULL-if format is not registered by a module.
nameconst char *Magick string (e.g. "GIF") which identifies this format.
nextMagickInfoNext MagickInfo struct in linked-list. NULL if none.
previousMagickInfoPrevious MagickInfo struct in linked-list. NULL if none.
rawunsigned intImage format does not contain size (must be specified in ImageInfo).





˜

Home Page9Image manipulation software that works like magic.