% Read/Write Graphviz DOT Format %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% July 1992 %
% %
% %
-% Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
% obtain a copy of the License at %
% %
-% http://www.imagemagick.org/script/license.php %
+% https://imagemagick.org/script/license.php %
% %
% Unless required by applicable law or agreed to in writing, software %
% distributed under the License is distributed on an "AS IS" BASIS, %
#undef HAVE_CONFIG_H
#include <gvc.h>
static GVC_t
- *graphic_context;
+ *graphic_context = (GVC_t *) NULL;
#endif
\f
#if defined(MAGICKCORE_GVC_DELEGATE)
static Image *ReadDOTImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
char
- command[MaxTextExtent];
+ command[MagickPathExtent];
const char
*option;
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
+ assert(graphic_context != (GVC_t *) NULL);
image=AcquireImage(image_info,exception);
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) CopyMagickString(read_info->magick,"SVG",MagickPathExtent);
(void) AcquireUniqueFilename(read_info->filename);
- (void) FormatLocaleString(command,MaxTextExtent,"-Tsvg -o%s %s",
+ (void) FormatLocaleString(command,MagickPathExtent,"-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)
- return ((Image *) 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");
gvLayout(graphic_context,graph,(char *) option);
gvRenderFilename(graphic_context,graph,(char *) "svg",read_info->filename);
gvFreeLayout(graphic_context,graph);
+ agclose(graph);
/*
Read SVG graph.
*/
+ (void) CopyMagickString(read_info->magick,"SVG",MaxTextExtent);
image=ReadImage(read_info,exception);
(void) RelinquishUniqueFileResource(read_info->filename);
read_info=DestroyImageInfo(read_info);
MagickInfo
*entry;
- entry=SetMagickInfo("DOT");
+ entry=AcquireMagickInfo("DOT","DOT","Graphviz");
#if defined(MAGICKCORE_GVC_DELEGATE)
entry->decoder=(DecodeImageHandler *) ReadDOTImage;
#endif
- entry->blob_support=MagickFalse;
- entry->description=ConstantString("Graphviz");
- entry->module=ConstantString("DOT");
+ entry->flags^=CoderBlobSupportFlag;
(void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("GV");
+ entry=AcquireMagickInfo("DOT","GV","Graphviz");
#if defined(MAGICKCORE_GVC_DELEGATE)
entry->decoder=(DecodeImageHandler *) ReadDOTImage;
#endif
- entry->blob_support=MagickFalse;
- entry->description=ConstantString("Graphviz");
- entry->module=ConstantString("DOT");
+ entry->flags^=CoderBlobSupportFlag;
(void) RegisterMagickInfo(entry);
#if defined(MAGICKCORE_GVC_DELEGATE)
graphic_context=gvContext();
(void) UnregisterMagickInfo("GV");
(void) UnregisterMagickInfo("DOT");
#if defined(MAGICKCORE_GVC_DELEGATE)
- gvFreeContext(graphic_context);
+ if (graphic_context != (GVC_t *) NULL)
+ {
+ gvFreeContext(graphic_context);
+ graphic_context=(GVC_t *) NULL;
+ }
#endif
}