This source file includes following definitions.
- ReadDOTImage
- RegisterDOTImage
- UnregisterDOTImage
#include "magick/studio.h"
#include "magick/blob.h"
#include "magick/blob-private.h"
#include "magick/client.h"
#include "magick/constitute.h"
#include "magick/exception.h"
#include "magick/exception-private.h"
#include "magick/image.h"
#include "magick/image-private.h"
#include "magick/list.h"
#include "magick/magick.h"
#include "magick/memory_.h"
#include "magick/monitor.h"
#include "magick/monitor-private.h"
#include "magick/option.h"
#include "magick/pixel-accessor.h"
#include "magick/quantum-private.h"
#include "magick/resource_.h"
#include "magick/static.h"
#include "magick/string_.h"
#include "magick/module.h"
#include "magick/utility.h"
#include "magick/xwindow-private.h"
#if defined(MAGICKCORE_GVC_DELEGATE)
#undef HAVE_CONFIG_H
#include <gvc.h>
static GVC_t
*graphic_context = (GVC_t *) NULL;
#endif
#if defined(MAGICKCORE_GVC_DELEGATE)
static Image *ReadDOTImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
char
command[MaxTextExtent];
const char
*option;
graph_t
*graph;
Image
*image;
ImageInfo
*read_info;
MagickBooleanType
status;
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
assert(graphic_context != (GVC_t *) NULL);
image=AcquireImage(image_info);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
return((Image *) NULL);
read_info=CloneImageInfo(image_info);
SetImageInfoBlob(read_info,(void *) NULL,0);
(void) CopyMagickString(read_info->magick,"SVG",MaxTextExtent);
(void) AcquireUniqueFilename(read_info->filename);
(void) FormatLocaleString(command,MaxTextExtent,"-Tsvg -o%s %s",
read_info->filename,image_info->filename);
#if !defined(WITH_CGRAPH)
graph=agread(GetBlobFileHandle(image));
#else
graph=agread(GetBlobFileHandle(image),(Agdisc_t *) NULL);
#endif
if (graph == (graph_t *) NULL)
{
(void) RelinquishUniqueFileResource(read_info->filename);
return ((Image *) NULL);
}
option=GetImageOption(image_info,"dot:layout-engine");
if (option == (const char *) NULL)
gvLayout(graphic_context,graph,(char *) "dot");
else
gvLayout(graphic_context,graph,(char *) option);
gvRenderFilename(graphic_context,graph,(char *) "svg",read_info->filename);
gvFreeLayout(graphic_context,graph);
agclose(graph);
image=ReadImage(read_info,exception);
(void) RelinquishUniqueFileResource(read_info->filename);
read_info=DestroyImageInfo(read_info);
if (image == (Image *) NULL)
return((Image *) NULL);
return(GetFirstImageInList(image));
}
#endif
ModuleExport size_t RegisterDOTImage(void)
{
MagickInfo
*entry;
entry=SetMagickInfo("DOT");
#if defined(MAGICKCORE_GVC_DELEGATE)
entry->decoder=(DecodeImageHandler *) ReadDOTImage;
#endif
entry->blob_support=MagickFalse;
entry->description=ConstantString("Graphviz");
entry->module=ConstantString("DOT");
(void) RegisterMagickInfo(entry);
entry=SetMagickInfo("GV");
#if defined(MAGICKCORE_GVC_DELEGATE)
entry->decoder=(DecodeImageHandler *) ReadDOTImage;
#endif
entry->blob_support=MagickFalse;
entry->description=ConstantString("Graphviz");
entry->module=ConstantString("DOT");
(void) RegisterMagickInfo(entry);
#if defined(MAGICKCORE_GVC_DELEGATE)
graphic_context=gvContext();
#endif
return(MagickImageCoderSignature);
}
ModuleExport void UnregisterDOTImage(void)
{
(void) UnregisterMagickInfo("GV");
(void) UnregisterMagickInfo("DOT");
#if defined(MAGICKCORE_GVC_DELEGATE)
if (graphic_context != (GVC_t *) NULL)
{
gvFreeContext(graphic_context);
graphic_context=(GVC_t *) NULL;
}
#endif
}