| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | #include "magick/studio.h" |
|---|
| 43 | #include "magick/blob.h" |
|---|
| 44 | #include "magick/blob-private.h" |
|---|
| 45 | #include "magick/client.h" |
|---|
| 46 | #include "magick/constitute.h" |
|---|
| 47 | #include "magick/exception.h" |
|---|
| 48 | #include "magick/exception-private.h" |
|---|
| 49 | #include "magick/image.h" |
|---|
| 50 | #include "magick/image-private.h" |
|---|
| 51 | #include "magick/list.h" |
|---|
| 52 | #include "magick/magick.h" |
|---|
| 53 | #include "magick/memory_.h" |
|---|
| 54 | #include "magick/monitor.h" |
|---|
| 55 | #include "magick/monitor-private.h" |
|---|
| 56 | #include "magick/option.h" |
|---|
| 57 | #include "magick/resource_.h" |
|---|
| 58 | #include "magick/quantum-private.h" |
|---|
| 59 | #include "magick/static.h" |
|---|
| 60 | #include "magick/string_.h" |
|---|
| 61 | #include "magick/module.h" |
|---|
| 62 | #include "magick/utility.h" |
|---|
| 63 | #include "magick/xwindow-private.h" |
|---|
| 64 | #if defined(MAGICKCORE_GVC_DELEGATE) |
|---|
| 65 | #undef HAVE_CONFIG_H |
|---|
| 66 | #include <gvc.h> |
|---|
| 67 | static GVC_t |
|---|
| 68 | *graphic_context; |
|---|
| 69 | #endif |
|---|
| 70 | |
|---|
| 71 | #if defined(MAGICKCORE_GVC_DELEGATE) |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | static Image *ReadDOTImage(const ImageInfo *image_info,ExceptionInfo *exception) |
|---|
| 99 | { |
|---|
| 100 | char |
|---|
| 101 | command[MaxTextExtent]; |
|---|
| 102 | |
|---|
| 103 | const char |
|---|
| 104 | *option; |
|---|
| 105 | |
|---|
| 106 | graph_t |
|---|
| 107 | *graph; |
|---|
| 108 | |
|---|
| 109 | Image |
|---|
| 110 | *image; |
|---|
| 111 | |
|---|
| 112 | ImageInfo |
|---|
| 113 | *read_info; |
|---|
| 114 | |
|---|
| 115 | MagickBooleanType |
|---|
| 116 | status; |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | assert(image_info != (const ImageInfo *) NULL); |
|---|
| 122 | assert(image_info->signature == MagickSignature); |
|---|
| 123 | if (image_info->debug != MagickFalse) |
|---|
| 124 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
|---|
| 125 | image_info->filename); |
|---|
| 126 | assert(exception != (ExceptionInfo *) NULL); |
|---|
| 127 | assert(exception->signature == MagickSignature); |
|---|
| 128 | image=AcquireImage(image_info); |
|---|
| 129 | status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); |
|---|
| 130 | if (status == MagickFalse) |
|---|
| 131 | return((Image *) NULL); |
|---|
| 132 | read_info=CloneImageInfo(image_info); |
|---|
| 133 | (void) CopyMagickString(read_info->magick,"PS",MaxTextExtent); |
|---|
| 134 | (void) AcquireUniqueFilename(read_info->filename); |
|---|
| 135 | (void) FormatMagickString(command,MaxTextExtent,"-Tps2 -o%s %s", |
|---|
| 136 | read_info->filename,image_info->filename); |
|---|
| 137 | graph=agread(GetBlobFileHandle(image)); |
|---|
| 138 | if (graph == (graph_t *) NULL) |
|---|
| 139 | return ((Image *) NULL); |
|---|
| 140 | option=GetImageOption(image_info,"dot:layout-engine"); |
|---|
| 141 | if (option == (const char *) NULL) |
|---|
| 142 | gvLayout(graphic_context,graph,(char *) "dot"); |
|---|
| 143 | else |
|---|
| 144 | gvLayout(graphic_context,graph,(char *) option); |
|---|
| 145 | gvRenderFilename(graphic_context,graph,(char *) "ps2",read_info->filename); |
|---|
| 146 | gvFreeLayout(graphic_context,graph); |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | |
|---|
| 150 | image=ReadImage(read_info,exception); |
|---|
| 151 | (void) RelinquishUniqueFileResource(read_info->filename); |
|---|
| 152 | read_info=DestroyImageInfo(read_info); |
|---|
| 153 | if (image == (Image *) NULL) |
|---|
| 154 | return((Image *) NULL); |
|---|
| 155 | return(GetFirstImageInList(image)); |
|---|
| 156 | } |
|---|
| 157 | #endif |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | |
|---|
| 161 | |
|---|
| 162 | |
|---|
| 163 | |
|---|
| 164 | |
|---|
| 165 | |
|---|
| 166 | |
|---|
| 167 | |
|---|
| 168 | |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | |
|---|
| 172 | |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | ModuleExport unsigned long RegisterDOTImage(void) |
|---|
| 183 | { |
|---|
| 184 | MagickInfo |
|---|
| 185 | *entry; |
|---|
| 186 | |
|---|
| 187 | entry=SetMagickInfo("DOT"); |
|---|
| 188 | #if defined(MAGICKCORE_GVC_DELEGATE) |
|---|
| 189 | entry->decoder=(DecodeImageHandler *) ReadDOTImage; |
|---|
| 190 | #endif |
|---|
| 191 | entry->blob_support=MagickFalse; |
|---|
| 192 | entry->description=ConstantString("Graphviz"); |
|---|
| 193 | entry->module=ConstantString("DOT"); |
|---|
| 194 | (void) RegisterMagickInfo(entry); |
|---|
| 195 | #if defined(MAGICKCORE_GVC_DELEGATE) |
|---|
| 196 | graphic_context=gvContext(); |
|---|
| 197 | #endif |
|---|
| 198 | return(MagickImageCoderSignature); |
|---|
| 199 | } |
|---|
| 200 | |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | |
|---|
| 206 | |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | |
|---|
| 211 | |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | |
|---|
| 218 | |
|---|
| 219 | |
|---|
| 220 | ModuleExport void UnregisterDOTImage(void) |
|---|
| 221 | { |
|---|
| 222 | (void) UnregisterMagickInfo("DOT"); |
|---|
| 223 | #if defined(MAGICKCORE_GVC_DELEGATE) |
|---|
| 224 | gvFreeContext(graphic_context); |
|---|
| 225 | #endif |
|---|
| 226 | } |
|---|